I have the following data and the following graph.
df <- data.frame(col1 = rnorm(1000, 0, 0.05), col2 = rnorm(1000, 0, 0.05))
ggplot(data = df, mapping = aes(x = col1, y = col2)) +
geom_pointdensity() +
scale_color_viridis()
To make a publication-quality figure, I’d like to change the legend title from "n_neighbors"
to "Point Density"
. I’ve tried a couple things, but neither of them worked.
ggplot(data = df, mapping = aes(x = col1, y = col2)) +
geom_pointdensity() +
scale_color_viridis() +
labs(fill = "Point Density")
ggplot(data = df, mapping = aes(x = col1, y = col2)) +
geom_pointdensity() +
scale_color_viridis() +
guides(fill = guide_legend(title = "Point Density"))
Is there a way to make this change?