How do I display only selected items in a ggplot2 legend? [duplicate]

…衆ロ難τιáo~ 提交于 2019-12-02 12:42:14

问题


I'm creating a stacked bar plot of relative abundance data, but I only want to display the ten most abundant organisms in the legend. How do I do this? I have no idea where to begin and haven't found any answers online.

Here's the plot with a full legend:

Thanks.


回答1:


As pointed out by user20650 in the comments, the answer is to add a list of selected items to the breaks= argument in scale_fill_manual()

scale_fill_manual(breaks=list,values=colpal)



来源:https://stackoverflow.com/questions/30076911/how-do-i-display-only-selected-items-in-a-ggplot2-legend

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!