Hi,

I have a problem with aligning text which I'm adding to a plot using
"mtext". I would like to specify the position of the right hand end of the
text string, relative to the device (in the left-right direction).

I've been looking at the use of the argument "adj". But this can't be used
to specify the rightmost point of the text. Neither does it specify exactly
the centre of the text, so I'm not sure exactly how it works.

I could hack it and change "adj" accordingly but this is part of a function
which I need to generalise. So it needs to be the same regardless of the
length of the added text, or the values on the x-axis.

Here's a simple example with two versions (the first three lines of each
version are identical). I would like the right end of the added text to be
the same distance from the legend in both versions.

### v1
dev.new()
plot(c(0,1),c(0,1),ylim=c(0,2))
legend("topright",c("data1","data2"),col=c(1,2),lty=1,bty="n")
mtext("text",side=3,line=-2,adj=0.8)

### v2
dev.new()
plot(c(0,1),c(0,1),ylim=c(0,2))
legend("topright",c("data1","data2"),col=c(1,2),lty=1,bty="n")
mtext("really long text",side=3,line=-2,adj=0.8)


Thank you for your help,
George

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to