简体   繁体   中英

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

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

在此处输入图片说明

I want the colour of text high to same as shape object ie 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?

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))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM