如何在R中没有图的情况下创建图例? [英] How can I create a legend without a plot in R?

查看:106
本文介绍了如何在R中没有图的情况下创建图例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个艺术项目.我创建了一个散点图,其中包含5种不同颜色的许多点.我想创建一个与图例完全分开的图例,因为它不在图上,也不在图的旁边,而是在它自己的窗口中,因此我可以将图例保存为它自己的.pdf文件.这样一来,我就可以分别打印我的剧情和图例,因为它们可以作为单独的部分挂在画廊中.

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.

我只想使用R重新创建此图像:

All I want is to recreate this image using R:

这有可能吗?

谢谢

周杰伦

推荐答案

好的.只是从一个空的情节开始,然后像使用情节一样使用图例.

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)

这篇关于如何在R中没有图的情况下创建图例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆