R中mtext的相对位置 [英] relative position of mtext in R

查看:66
本文介绍了R中mtext的相对位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在 R 绘制的图表中写入文本时,我使用 mtext 命令.例如,要在图形的左上角(内部)写一个索引(例如 (a),(b) ),我可以这样做

when I write text in the graph plotted by R, i use mtext command. for example, to write a index (e.g. (a),(b) ) on the top left of a graph (inside), I can do

mtext("(c)",side=3,line=-1.5,at=0.05,cex=1.2)

然而,参数at是x轴的坐标.当 x 轴上的值范围不同时,这有点烦人(必须更改每个图形的 at 值).有人可以建议将文本写为相对值吗?

However, the parameter at is the coordinates of x-axis. this is a bit annoying when the value range on x-axis is different (one has to change the at value for each graph). can someone give a suggestion to write text as relative values?

提前致谢!

推荐答案

您选择的 'line' 参数会将其放置在绘图区域内,但我想这可能是有意的:

Your choice of the 'line' parameter places it inside the plot area but that may be intentional I suppose:

 mtext("(c)",side=3,line=-1.5, 
             at=par("usr")[1]+0.05*diff(par("usr")[1:2]),
             cex=1.2)

它位于x 轴"的二十分之一处.

That places it about one-twentieth of the way across the "x-axis".

这篇关于R中mtext的相对位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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