繁体   English   中英

使用 ggmap 映射点

[英]Mapping points using ggmap

数据是

> head(latlon1.df)
       lat       lon
1 35.86417 -95.65556
2 29.72333 -98.69444
3 29.52917 -97.46417
4 40.82806 -72.86556
5 26.73500 -81.05111
6       NA        NA
ggmap(usa) +
  geom_point(data = latlon1.df, mapping = aes(x = latlon1.df$lon, y = latlon1.df$lat), color = "red",size=1)

不断获得

mapping: x = ~latlon1.df$lon, y = ~latlon1.df$lat 
geom_point: na.rm = FALSE
stat_identity: na.rm = FALSE

and I do not get a map or points The map was loaded with ggmap and works correctly as a map but the points do not appear on the map position_identity

您的示例不是代表,因为您既没有提供ggmap被称为 [minor] 的库, ggmap没有提供usa数据集的(样本)(或获取它的参考)[major]。 另外,请使用dput()dput(head())发布您的输入数据,而不是head()

不是每个人都熟悉每个 R package。 请通过帮助我们帮助您来帮助自己。

也就是说,我怀疑您的问题是您在geom_point中使用的语法。 我怀疑您不需要在对aes的调用中重复数据框名称。 这是一个表示在不同几何图形中使用不同数据源时的正确用法的代表。

library(tidyverse)
set.seed(123)

x <- tibble(x=rnorm(10), y=rnorm(10))
y <- tibble(x=c(0, 1), y=c(0, 1))

x %>% 
  ggplot() +
  geom_point(aes(x=x, y=y)) +
  geom_line(data=y, aes(x=x, y=y), colour="red")

在此处输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM