[R] scaling with relative units in plots or retrieving axes limits in plots

Joshua Wiley jwiley.psych at gmail.com
Tue May 18 16:35:35 CEST 2010


par("usr") #gives the extreme plotting coordinates

?par

HTH,

Josh

On Tue, May 18, 2010 at 7:32 AM, Jannis <bt_jannis at yahoo.de> wrote:
> Dears,
>
>
> a way to define x and y positions in plots in relative numbers (e.g in fractions  between 0 and 1 referring to relative positions inside the plot region) would really help me. One example I would need this to would be to add text via text() to a plot always at a defined spot, e.g the upper left corner. Until now I always determined maximum x and y values and used those, but defining relative positions straight away would be much easier. Possible solutions:
>
> 1. Predefined function
> Is there anything available that lets me run (for example):
>
> text(0.5,0.5,'middle')
>
> which always puts text on these relative points?
>
>
>
> 2. Create my own function
> It would be straightforward to create my own function that translates the relative number to the axes values in the actual plot, so that
>
> text(my.function(0.5,0.5),'middle')
>
> would do what I want. For this I would need to be able to somehow retrieve the axis limits for x and y axes. Is there any way I could do this after having called plot()?
>
>
>
> Thanks for your help!
>
>
> Jannis
>
>
>
>
> ______________________________________________
> 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.
>



-- 
Joshua Wiley
Senior in Psychology
University of California, Riverside
http://www.joshuawiley.com/



More information about the R-help mailing list