I'm making a map using ggplot and geom_sf and I want to add commas to the values in the legend. The only way I've found to edit a color bar is through "guides", but + guides(fill = guide_colorbar(labels="comma"))
doesn't seem to do anything (maybe because "labels" is not a specification included in "guides"?) How do I get an identical legend that includes commas in numbers over 1,000?
The code to get all the data is a little long so I'm hoping someone knows the answer without a reprex, but I can edit it in if needed. Thanks!
landingsmap <- ggplot() +
scale_x_continuous(limits=c(-126, -116), expand=c(0,0)) +
scale_y_continuous(limits=c(32, 42), expand=c(0,0)) +
geom_sf(data=simpleblocks, aes(colour=number_fish, fill=number_fish)) +
scale_colour_gradient(low="lightcoral", high="darkred", name="Number of Fish") +
scale_fill_gradient(low="lightcoral", high="darkred", name="Number of Fish") +
geom_sf(data=camap, colour="black") +
theme(
panel.background = element_rect(fill="skyblue4", size=0.5, linetype="solid"),
legend.position = c(0.78, 0.5)
) +
NULL
landingsmap