Reputation: 79
Using the following code generates this plot
ggplot(df_44, aes(x = latest_tli_date, y = farmer_created_at, fill = ward_id)) +
geom_point()+ scale_color_brewer(palette = "BuPu")
I need the 4 wards to have different colours. What am I doing wrong?
Upvotes: 0
Views: 81
Reputation:
try using the fill argument in the geom_point
function
Edit: I just tried an example code, the fill and col arguments is going to color it with on a continuous scale because the data is continuous.
If you factor your value you want to color, it should color it discretely.
ggplot(df_44, aes(x = latest_tli_date, y = farmer_created_at)) +
geom_point(aes(col = factor(ward_id))
Upvotes: 2
Reputation: 79311
Use colour
aesthetics:
If ward_id
is numeric then you might want to replace by colour = factor(ward_id):
Have a look here: https://ggplot2.tidyverse.org/reference/scale_brewer.html
library(ggplot2)
ggplot(df_44, aes(x = latest_tli_date, y = farmer_created_at, colour = ward_id)) +
geom_point()+ scale_color_brewer(palette = "BuPu")
Upvotes: 1