Add numbers to ggplot legend

一曲冷凌霜 提交于 2019-12-25 15:16:42

问题


I've done the following plot so far:

Is it possible to add numbers from 1 to x inside the square where there's the color in the legend, and add a label inside the pie-chart referencing to the number instead of adding the entire label?

EDIT. Code:

 ggplot(BP, aes(x=1, y=Enrichment_Score, fill=GO.ID)) +
    geom_bar(stat="identity") +
    coord_polar(theta='y') +
    guides(fill=guide_legend(override.aes=list(colour=NA), nrow=6)) +
    theme(axis.ticks=element_blank(), axis.title=element_blank(), axis.text=element_blank(), panel.grid  = element_blank(), legend.position="bottom") +
    ggtitle("Biological Processes")

Data (just few rows):

GO.ID                                       Enrichment_Score
kinetochore organization                    18.085646
defense response to Gram-negative bacterium 18.085646
cell wall repair                            18.085646

来源:https://stackoverflow.com/questions/26358052/add-numbers-to-ggplot-legend

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