ggplot 图例列表大于页面

ggplot legend list is larger than page

我在 R 中有一个图,其中包含大量样本组,因此图例大于页面大小并被截断。我知道这不是出版质量,但我需要知道颜色才能在 Illustrator 中制作图例。

有没有办法使页面大小更大或以某种方式更改图例格式以便我可以包含所有键?这样做的原因是我可以在 Illustrator 中打开 PDF 并获取每个样本的颜色以创建将要发布的新图例。我想也许有一个剪贴蒙版,并且实际的图例将被保留,但是当我在 Illustrator 中打开时,图例实际上在页尾处被剪切了1。

正如下面评论中所建议的那样,我尝试了 nrow 这有助于打破图例,但现在整个页面都只是图例。

ggplot(purine.n, aes(x=variable, y=value, colour=metabolite_gene, shape=variable))
+geom_abline(slope=0)
+geom_point(size=4, position=position_dodge(width=0.08))
+scale_y_continuous(limit=c(-3.5,5.5), breaks=c(-3,-2,-1,0,1,2,3,4,5))
+scale_shape_manual(values=c(16,17,17), guide=F)
+theme_bw()
+theme(legend.key=element_blank(), legend.key.size=unit(1,"point"))
+guides(colour=guide_legend(nrow=16))

正如评论中所建议的那样,nrow 是我问题的答案。我必须调整该值以获得适合我的图例的正确行数。下面是完整的有效代码。我需要做更多的调整,比如更改页面大小以帮助让事情看起来更好,但这超出了这个问题的范围。

ggplot(data.n, aes(x=variable, y=value, colour=metabolite_gene, shape=variable))
+geom_abline(slope=0)+geom_point(size=4, position=position_dodge(width=0.08))
+scale_y_continuous(limit=c(-3.5,5.5), breaks=c(-3,-2,-1,0,1,2,3,4,5))
+scale_shape_manual(values=c(16,17,17), guide=F)
+theme_bw()
+theme(legend.key=element_blank(), legend.key.size=unit(1,"point"))
+guides(colour=guide_legend(nrow=30))