001、正常绘图
library(ggplot2) bp <- ggplot(data=PlantGrowth, aes(x=group, y=weight, fill=group)) + geom_boxplot() bp ## 显示绘图结果
002、修改图例标题的名称
bp + scale_fill_discrete(name="Experimental\nCondition") ## 修改图例标题的名称
003、同时修改图例标题名称、图例名称
bp + scale_fill_discrete(name="Experimental\nCondition", breaks=c("ctrl", "trt1", "trt2"), labels=c("Control", "Treatment 1", "Treatment 2"))
绘图结果如下:
标签:标题,修改,图例,绘图,bp,ggplot2 From: https://www.cnblogs.com/liujiaxin2018/p/17248275.html