我无法更改图中的细分图例的颜色。我需要两种不同的颜色作为图例中的文本以及视觉绘图中的文本。
er<- ggmap(sq_map2) +
geom_point(data = sisquoc, size = 3, aes(fill = Segmentation)) +
geom_line(data = sisquoc, size = 3, aes(color =SpeedMeterPerSecond)) +
geom_text(data = sisquoc, aes(label = paste(" ",
as.character(Location_ids), sep="")),
angle = 60, hjust = 0, color = "sienna4",size = 6 )
gg<- er + labs(x ="Longitude", y = "Latitude") +
theme(axis.title = element_text(size=20),
panel.background = element_rect(fill = "white",size = 0.5, linetype =
"dotted"),
panel.grid.major = element_line(size = 0.5, linetype = 'dotted',colour
= "black"),
panel.grid.minor = element_line(size = 0.5, linetype = 'dotted',colour
= "black"),
panel.border = element_rect(colour = "black", fill=NA, size=0.5),
axis.text.y = element_text(size=18),
axis.text.x = element_text(size=18))
gg + theme(legend.position="right",
legend.title = element_text(colour="Black", size=18),
legend.text = element_text(colour="black", size = 15),
legend.background = element_rect(fill="grey90",
size=0.5, linetype="solid",
colour ="black")) + scale_color_continuous(name="Speed (m/s)\n")
像下面这样的东西应该起作用。只需显式指定图例标题并\n
在字符串的末尾添加,这将添加一个额外的空白行:
ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width, col=Petal.Length))+
geom_point() + scale_color_continuous(name="my scale\n")
或者,您可以尝试更改图例的方向,但是,当图例位于底部时,这通常是最紧凑的。
ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width, col=Petal.Length))+
geom_point() + theme(legend.direction = "horizontal", legend.position = "bottom")
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句