Reputation: 115
This is question linked to previous question (Adjusting legend.title ,legend.text and legend color in ggplot2). I am having issue to change color of the geom points (Run and Walk Segmentation) in the plot. Can anyone please help me in this ? Is there any other way that i can have more better visualizations for the segmentation ? Thanks
er<- ggmap(sq_map2) +
geom_point(data = sisquoc, size = 8, 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")
Upvotes: 0
Views: 85
Reputation: 3369
For geom_point
to make use of aes(fill=...)
you have to select shapes that can take fill values in addition to colour values, otherwise geom_point
takes aes(colour=...)
. Fill is the appropriate aes
to use here since you are already making use of aes(colour=...)
for geom_line
.
See possible shapes 21 to 25 that take fill values here
Try:
ggmap(sq_map2) +
geom_point(data = sisquoc, size = 8, aes(fill = Segmentation, shape = Segmentation) +
scale_shape_manual(values=c(21, 24))
You can further define fill values using e.g. scale_fill_manual(values=c("red", "blue"))
Upvotes: 1
Reputation: 73
I assume that you want to change the colour of the points in the plot.
try + scale_fill_manual(values = c("Run" = "black","Walk" = "grey"))
Upvotes: 2