r - 使用 mtext 函数时的 'pos' 等效项
问题描述
我通常使用 mtext 为图形添加标签。我经常希望在图形的左上角绘制标签。使用 par('usr')[1] 很容易,只是文本居中而不是我想要的右向。使用“文本”时,我会使用 pos=4,但对于 mtext,似乎没有等效的。例子:
plot(1)
text(par('usr')[1], 1.5, "test", xpd=TRUE, pos=4)
mtext('test', 3, at=par('usr')[1])
我想避免简单地将值添加到 at= 或使用 adj=,因为我经常用不同的轴绘制多个面板。
解决方案
adj=
在基图中使用:
plot(1)
usr <- par("usr")
text(usr[1], usr[3], adj = c(-0.1, -0.1), "lower-left")
text(usr[2], usr[3], adj = c( 1.1, -0.1), "lower-right")
text(usr[1], usr[4], adj = c(-0.1, 1.1), "upper-left")
text(usr[2], usr[4], adj = c( 1.1, 1.1), "upper-right")
来自?text
:
adj: one or two values in [0, 1] which specify the x (and optionally y) adjustment ('justification') of the labels, with 0 for left/bottom, 1 for right/top, and 0.5 for centered. On most devices values outside [0, 1] will also work. See below.
我使用-0.1
and1.1
从边缘线本身插入一点。该.1
组件可能需要根据绘图的其余部分进行调整。
推荐阅读
- python - Python - 覆盖继承的单例类方法
- wordpress - 如何在 WooCommerce 上基于 2 个属性显示产品?
- django - 如何在没有 Django 表单的 Django 模板中使用 CKEDITOR 并保存数据
- reactjs - React Router Link 无法克隆功能
- c - scanf("%f",&aa) VS scanf("%f",&aa) 在 while 循环中
- google-cloud-firestore - Dialogflow - Firestore - Webhook 调用失败。错误:UNAVAILABLE,状态:URL_UNREACHABLE,原因:UNREACHABLE_5xx,HTTP 状态代码:500
- python-3.x - 我如何在 python3 上使用 sys.stdout.flush()
- windows - 请如何解决在窗口上安装火花的这些错误。请任何人帮助找到这些错误的解决方案。我无法启动项目
- javascript - 如何按 id 和 name 对对象数组进行排序?
- python - 定义函数以删除异常值