如何在 R 中为 28 个多图案例添加注释? [英] How to add annotations to a 28 multi-plot case in R?

查看:50
本文介绍了如何在 R 中为 28 个多图案例添加注释?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个可容纳 28 个地块的空平台:

par(mfcol = c(7, 4), mar = rep(.1, 4), oma = rep(5, 4))

lapply(1:28, plot, t = "n", xaxt = "n", yaxt = "n")

问题

我想知道如何将我在下面显示的所有注释添加到我的上方的 28 个图的空平台(一些示例显示了如何添加一些注释)这些注释中的一部分将使我前进):

Question

I'm wondering how I could add all the annotations that I'm showing below to my above empty platform for 28 plots (a few examples showing how to add some of these annotations will get me going):

推荐答案

这些注释对我来说总是很挑剔,但作为一个开始:

These annotations are always finicky to me, but as a start:

par(mfcol = c(7, 4), mar = rep(.1, 4), oma = rep(10, 4))

lapply(1:28, plot, t = "n", xaxt = "n", yaxt = "n")

l <- rep('Very Strong\n23%', 7)

at <- seq(grconvertY(0 + (1 / 14), "nic"), grconvertY(1 - (1 / 14), "nic"), l = 7)

mtext(l, 4, at = at, las = 1, line = 1)

所以这里棘手的部分是坐标,对于 mtext 定义为用户坐标.不过,我们可以使用 grconvertXgrconvertYnic 坐标转换为用户坐标.这些是范围从 0 到 1 的标准化内部区域坐标".因此对于面板中间的 7 个数字,我们需要一个从 0 + (1/14)1 - 的序列 -(1/14).您可以对其他文本使用类似的逻辑.

So the tricky part here are the coordinates, which for mtext are defined as user coordinates. We can translate nic coordinates towards user coordinates with grconvertX and grconvertY though. These are "normalized inner region coordinates" ranging from 0 to 1. So for 7 number in the middle of the panels, we need a sequence from 0 + (1 / 14) to 1 - (1 / 14). You can use similar logic for the other text.

添加更多 mtext 调用会让您大有作为.

Adding more mtext calls will get you a long way.

这篇关于如何在 R 中为 28 个多图案例添加注释?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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