【发布时间】:2017-10-25 11:31:12
【问题描述】:
我无法更改图中分段图例的颜色。我需要两种不同的颜色作为图例和视觉图中的文本。
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")
【问题讨论】:
-
最简单的可能是添加
+scale_color_continuous(name="Speed (m/s)\n") -
谢谢,但我遇到了错误。 + scale_color_continuous(name="Speed (m/s)\n") +scale_color_continuous(name = "Speed (m/s)\n") 中的错误:一元运算符的参数无效
-
嗯,奇怪。您确定错误不会在您的代码中的其他地方发生,即当您省略
+scale_color_conti...时是否会发生错误? -
顺便说一句,您应该根据答案更改原始问题的代码/输入。否则人们将无法理解问题应该解决的问题
-
那是说“你应该不...”:-)