我正在使用ggplot,因此我可以在地图上获得一个渐变来大规模显示数据。可以看到0到35,000之间的点。我有这个工作,但图例会自动显示每10,000个标签。
理想情况下,我希望图例显示最大数量,因此可能只会在底部显示0,在顶部显示35,000。这可行吗?
如果这有帮助,我的ggplot代码如下。
ggplot() +
geom_map(data = datafile, aes(map_id = Health_Board, fill = datafile$"2007"), map = Scot) +
geom_polygon(data = Scot, aes(x = long, y = lat, group = group), colour = "gray", fill = NA) +
expand_limits(x = Scot$long, y = Scot$lat) +
scale_fill_gradient(low = ("lightyellow"), high = ("red"), limits = c(0,35000)) +
ggtitle("2007") +
coord_fixed(1.2) +
theme(axis.text.x = element_blank(), axis.text.y = element_blank(),
axis.ticks = element_blank(), axis.title.x = element_blank(),
axis.title.y = element_blank(),
panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
panel.border = element_blank(), panel.background = element_blank(),
legend.title = element_text(face = "bold"),
plot.title = element_text(face = "bold", hjust = 0.5))
答案 0 :(得分:1)
您可以包含“休息”参数。像这样:
scale_fill_gradient(low = ("lightyellow"), high = ("red"),
breaks=c(min(lat),max(lat)),
limits = c(0,35000)) +
如果您想要更多,可以包含“标签”参数。
scale_fill_gradient(low = ("lightyellow"), high = ("red"),
breaks=c(min(lat),max(lat)),
labels=c("Minimum","Maximum"),
limits = c(0,35000)) +