0

数据是

> 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

我没有得到地图或点地图已加载 ggmap 并作为地图正常工作,但点未出现在地图 position_identity

4

1 回答 1

0

您的示例不是代表,因为您既没有提供ggmap被称为 [次要] 的库,也没有提供数据集的(样本)usa(或对可以获取它的位置的引用)[主要]。另外,请使用dput()dput(head())发布您的输入数据,而不是head().

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

也就是说,我怀疑您的问题是您在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")

在此处输入图像描述

于 2021-03-08T07:33:37.120 回答