Hi there, I hope to rotate the Y label of axis(4) with -90 degree. I can typeset the Y label using text() with srt = -90. However, I cannot get the coordinate of the position that mtext() used. In other words, I hope to convert: mtext("Y label", side = 4, at = 0, line = 2) to text(x, 0, "Y label", str = -90) Now, I don't know how to get the x in the above expression. I can give it an arbitrary value. However, I hope it could be more precise. Thanks a lot for any suggestions. Regards, Jinsong
On 03/18/2014 09:18 AM, Jinsong Zhao wrote:> Hi there, > > I hope to rotate the Y label of axis(4) with -90 degree. I can typeset > the Y label using text() with srt = -90. However, I cannot get the > coordinate of the position that mtext() used. > > In other words, I hope to convert: > mtext("Y label", side = 4, at = 0, line = 2) > to > text(x, 0, "Y label", str = -90) > > Now, I don't know how to get the x in the above expression. I can give > it an arbitrary value. However, I hope it could be more precise. >Hi Jinsong, If you mean the distance from the axis, mtext is placed by a multiple of the height of a line of text. Therefore: strheight("O") * 2 will give you an approximate distance in user units. You can then add this to the user coordinate of the right ordinate of the plot: par("usr")[2] to get your "x" value. You will probably want to adjust this to get the desired visual spacing. Jim
David McPearson
2014-Mar-18 09:27 UTC
[R] is it possible to get the coordinate of mtext()?
On Mon, 17 Mar 2014 15:18:50 -0700 Jinsong Zhao <jszhao at yeah.net> wrote> Hi there, > > I hope to rotate the Y label of axis(4) with -90 degree. I can typeset > the Y label using text() with srt = -90. However, I cannot get the > coordinate of the position that mtext() used. ><...cut...> locator(1) # Works for me... ?locator Cheers, D. ____________________________________________________________ South Africas premier free email service - www.webmail.co.za Cotlands - Shaping tomorrows Heroes http://www.cotlands.org.za/