【发布时间】:2020-07-11 06:29:23
【问题描述】:
我有这些文件和数据:
还有这个脚本:
#open shp file
library(rgdal)
map <- readOGR(dsn= "/rj_municipios", layer = "33MUE250GC_SIR")
#open data file
ind_mapa <- read.csv("ind_mapa.csv", sep=";")
#map
library(ggplot2)
library(ggrepel)
mapdf <-fortify(map)
ggplot(data= mapdf, aes(x=long, y=lat, group=group)) +
geom_path() +
coord_map("mercator") +
xlim(-42.040,-41.973)+
ylim(-23.015, -22.949)+
theme_bw() +
geom_jitter(data=ind_mapa, width= .0015, height = .0015, size=3,alpha=.7,
aes(x=lon, y=lat, group= code, color = code)) +
geom_text_repel(data= ind_mapa, aes(x=lon, y=lat), group= code, label=ano)
我有两个问题,标签“ano”没有出现:
层错误(数据 = 数据,映射 = 映射,stat = stat,geom = GeomTextRepel,:找不到对象“代码”
我使用 geom_jitter 使点不会重叠,但它们会变得混乱,而不是均匀分布在原始点和中心点上。
【问题讨论】:
-
您可能在
geom_jitter和geom_text_repel中都需要inherit.aes = FALSE -
我刚试了一下,还是一样
标签: r dictionary ggplot2 point rgdal