自定义图例
ggplot(data=data1,aes(x=genome,y=isoformCount,fill=type))+
geom_bar(stat = "identity")+
guides(
fill=guide_legend(
direction = 'vertical',
title=NULL,
label.theme=element_text(angle = 90,size = 20), ##修改图例label的角度和大小
label.vjust = 1.2,
label.position='top',
reverse=F))图例函数:
guide_colorbar()/guide_colourbar()用于连续变量的图例guide_legend()用于离散变量的图例,也可以用于连续变量guides()将_colorbar和_legend嵌套进去,方便映射,如guides(fill = guide_colorbar())可以在
scale_xxx()标度中指定guide类型,guide = "colorbar"或guide = “legend”
fill映射
使用guide_legend修改图例的各个部件:
direction修改图片的方向title图例标题label.theme使用element_text对文字颜色、大小、方向进行修改label.position在图例处的位置reverse是否翻转图例
修改图例label
修改图例位置
使用位置坐标
或者使用关键字
top、bottom等
修改图例中图形属性
多个重叠图例时,只需要指定相同的title,自动的就合并在一起了
Last updated
Was this helpful?