Dear R-helpers, I wish to place some text in a plot, at approx 10% of my upper xlim and approx 90% of my upper ylim, i.e.> plot(log(all$SR,10)~log(all$AREA,10)) > text(.1*max(xlim),.9*max(ylim),"text to be placed")(I know how to give absolute coordinates for text location, but I wish to use relative coordinates). My code (above) doesn't work because I don't know how to properly extract the upper xlim and ylim values. Does anyone know how I could extract the upper xlim and ylim values (without using max(x-variable) or max (y-variable)...I wish to keep this as general as possible and not point to the original data. Thanks in advance, Mark [[alternative HTML version deleted]]
Peter Alspach
2009-Jul-21 21:12 UTC
[R] How to extract the upper xlim and ylim of my plot?
Tena koe Mark ?par in particular usr parameter, accessible by par()$usr HTH .... Peter Alspach> -----Original Message----- > From: r-help-bounces at r-project.org > [mailto:r-help-bounces at r-project.org] On Behalf Of Mark Na > Sent: Wednesday, 22 July 2009 9:04 a.m. > To: r-help at r-project.org > Subject: [R] How to extract the upper xlim and ylim of my plot? > > Dear R-helpers, > > I wish to place some text in a plot, at approx 10% of my > upper xlim and approx 90% of my upper ylim, i.e. > > > plot(log(all$SR,10)~log(all$AREA,10)) > > text(.1*max(xlim),.9*max(ylim),"text to be placed") > > (I know how to give absolute coordinates for text location, > but I wish to use relative coordinates). > > My code (above) doesn't work because I don't know how to > properly extract the upper xlim and ylim values. > > Does anyone know how I could extract the upper xlim and ylim > values (without using max(x-variable) or max (y-variable)...I > wish to keep this as general as possible and not point to the > original data. > > Thanks in advance, > > Mark > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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. >The contents of this e-mail are confidential and may be subject to legal privilege. If you are not the intended recipient you must not use, disseminate, distribute or reproduce all or any part of this e-mail or attachments. If you have received this e-mail in error, please notify the sender and delete all material pertaining to this e-mail. Any opinion or views expressed in this e-mail are those of the individual sender and may not represent those of The New Zealand Institute for Plant and Food Research Limited.
May be: text(.1*max(all$AREA),.9*max(all$SR),"text to be placed") ? bests milton On Tue, Jul 21, 2009 at 5:03 PM, Mark Na <mtb954@gmail.com> wrote:> Dear R-helpers, > > I wish to place some text in a plot, at approx 10% of my upper xlim and > approx 90% of my upper ylim, i.e. > > > plot(log(all$SR,10)~log(all$AREA,10)) > > text(.1*max(xlim),.9*max(ylim),"text to be placed") > > (I know how to give absolute coordinates for text location, but I wish to > use relative coordinates). > > My code (above) doesn't work because I don't know how to properly extract > the upper xlim and ylim values. > > Does anyone know how I could extract the upper xlim and ylim values > (without > using max(x-variable) or max (y-variable)...I wish to keep this as general > as possible and not point to the original data. > > Thanks in advance, > > Mark > > [[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. >[[alternative HTML version deleted]]
Marc Schwartz
2009-Jul-21 21:15 UTC
[R] How to extract the upper xlim and ylim of my plot?
On Jul 21, 2009, at 4:03 PM, Mark Na wrote:> Dear R-helpers, > > I wish to place some text in a plot, at approx 10% of my upper xlim > and > approx 90% of my upper ylim, i.e. > >> plot(log(all$SR,10)~log(all$AREA,10)) >> text(.1*max(xlim),.9*max(ylim),"text to be placed") > > (I know how to give absolute coordinates for text location, but I > wish to > use relative coordinates). > > My code (above) doesn't work because I don't know how to properly > extract > the upper xlim and ylim values. > > Does anyone know how I could extract the upper xlim and ylim values > (without > using max(x-variable) or max (y-variable)...I wish to keep this as > general > as possible and not point to the original data. > > Thanks in advance, > > MarkMark, par("usr") after the plot has been created will give you the x,y corner extremes of the plot region in user coordinates. See ?par and scroll down to 'usr'. HTH, Marc Schwartz
?grconvertX -----Original Message----- From: "Mark Na" <mtb954 at gmail.com> To: "r-help at r-project.org" <r-help at r-project.org> Sent: 7/21/09 3:05 PM Subject: [R] How to extract the upper xlim and ylim of my plot? Dear R-helpers, I wish to place some text in a plot, at approx 10% of my upper xlim and approx 90% of my upper ylim, i.e.> plot(log(all$SR,10)~log(all$AREA,10)) > text(.1*max(xlim),.9*max(ylim),"text to be placed")(I know how to give absolute coordinates for text location, but I wish to use relative coordinates). My code (above) doesn't work because I don't know how to properly extract the upper xlim and ylim values. Does anyone know how I could extract the upper xlim and ylim values (without using max(x-variable) or max (y-variable)...I wish to keep this as general as possible and not point to the original data. Thanks in advance, Mark [[alternative HTML version deleted]] ______________________________________________ R-help at 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.