How can I manually add an arbitrary suffix to the legend ticks in ggplot?
For example, can I add something to the below code to generate the below plot with those unique legend ticks?
ggplot(iris, aes(Sepal.length, Sepal.Width, color = Species)) geom_point()
Note that I manually added "(s)" to the end of the legend ticks using Photoshop.
CodePudding user response:
We can use the labels
argument in scale_color_discrete
. This can take an rlang
style lambda function that pastes an "(S)" at the end.
ggplot(iris, aes(Sepal.Length, Sepal.Width, color = Species))
geom_point()
scale_color_discrete(labels = ~paste(.x, "(S)"))