Sunny Sunny
Sunny Sunny

Reputation: 3230

Changing colour of legend text same as mentioned colour of geom_point() using ggplot2

I have legend having three values namely - high low med.

enter image description here

I want the colour of text high to same as shape object i.e blue and low as red and med as green Colour are mentioned in geom_point().

Is it possible to change the colour of legend text?

Upvotes: 2

Views: 229

Answers (1)

baptiste
baptiste

Reputation: 77124

If p is your plot, you can save it as a grob and edit the labels one-by-one with grid commands,

g = ggplotGrob(p)
grid.draw(g)
grid.edit("label-3", grep=TRUE, global=TRUE,
           gp=gpar(col="red", cex=1))

Upvotes: 1

Related Questions