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)
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?
Thanks in advance!
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)
That places it about one-twentieth of the way across the "x-axis".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With