我如何在R中创建一个没有阴谋的图例?(How can I create a legend without a plot in R?)

这是一个艺术项目。 我创建了一个带有5种不同颜色点的散点图。 我想创建一个完全独立于绘图的图例,因为它不在绘图上,也不在绘图旁边,而是在它自己的窗口中,所以我可以将图例保存为它自己的.pdf文件。 这样我就可以将我的情节和图例单独打印出来,因为它们可以作为单独的部件挂在画廊中。

我想要的只是使用R重新创建这个图像:

这甚至有可能吗?

谢谢,

松鸦

This is for an art project. I've created a scatterplot with many dots of 5 different colours. I want to create a legend that is completely separate from the plot, as in it is not on the plot, nor beside the plot, but is in it's own window so I can save the legend as it's own .pdf file. This is so I can have my plot and legend printed separately as they well be hung in a gallery as separate pieces.

All I want is to recreate this image using R:

Is this even possible?

Thanks,

Jay

最满意答案

当然。 从一个空的情节开始,然后像使用图例一样,如果有情节。

plot(NULL ,xaxt='n',yaxt='n',bty='n',ylab='',xlab='', xlim=0:1, ylim=0:1) legend("topleft", legend =c('Sugar maple', 'White ash', 'Black walnut', 'Red oak', 'Eastern hemlock'), pch=16, pt.cex=3, cex=1.5, bty='n', col = c('orange', 'red', 'green', 'blue', 'purple')) mtext("Species", at=0.2, cex=2)

没有情节的传说

Sure. Just start from an empty plot and then use legend as you would if there were a plot.

plot(NULL ,xaxt='n',yaxt='n',bty='n',ylab='',xlab='', xlim=0:1, ylim=0:1) legend("topleft", legend =c('Sugar maple', 'White ash', 'Black walnut', 'Red oak', 'Eastern hemlock'), pch=16, pt.cex=3, cex=1.5, bty='n', col = c('orange', 'red', 'green', 'blue', 'purple')) mtext("Species", at=0.2, cex=2)

Legend without a plot

更多推荐