Dear R-users, I am trying to produce (standard and trellis) scatterplots which use the same range of the x and y axes. In addition, I would like the plots to be physically square. Is there one or more specific argument(s) to plot and xyplot what would do that? I have looked at various combinations of asp and pin value, but could not get what I wanted.. Thank you in advance for your help Sebastien
How to force axis to have the same range
8 messages · Dieter Menne, David Winsemius, Rodrigo Aluizio +3 more
Sebastien Bihorel <Sebastien.Bihorel <at> cognigencorp.com> writes:
I am trying to produce (standard and trellis) scatterplots which use the same range of the x and y axes. In addition, I would like the plots to be physically square. Is there one or more specific argument(s) to plot and xyplot what would do that? I have looked at various combinations of asp and pin value, but could not get what I wanted..
In lattice : aspect = 1 Dieter
On Apr 20, 2009, at 12:18 PM, Dieter Menne wrote:
Sebastien Bihorel <Sebastien.Bihorel <at> cognigencorp.com> writes:
I am trying to produce (standard and trellis) scatterplots which use the same range of the x and y axes. In addition, I would like the plots to be physically square. Is there one or more specific argument(s) to plot and xyplot what would do that? I have looked at various combinations of asp and pin value, but could not get what I wanted..
In lattice : aspect = 1
To satisfy both of his requests with xyplot, I think he also needs xlim and ylim: xy <-data.frame(x=1:10, y= rnorm(10)+5) xyplot(y ~ x, data=xy, aspect=1) xyplot(y ~ x, data=xy, aspect=1, ylim=c(0,11), xlim=c(0,11)) I was less successful in using xlim and ylim with plot, since it seems to handle the x-axis differently than the y-axis as far as padding out beyond the limits. I would typically need to set asp=0.85 to get what looked to ba a square plot. Suggest reading the documentation for plot.window() as a start.
David Winsemius, MD Heritage Laboratories West Hartford, CT
Hi Sebastien, take a look at the par(pty='s') argument. Maybe its can solve your issue. Best wishes. Rodrigo. -----Mensagem original----- De: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] Em nome de Sebastien Bihorel Enviada em: segunda-feira, 20 de abril de 2009 12:26 Para: R-help Assunto: [R] How to force axis to have the same range Dear R-users, I am trying to produce (standard and trellis) scatterplots which use the same range of the x and y axes. In addition, I would like the plots to be physically square. Is there one or more specific argument(s) to plot and xyplot what would do that? I have looked at various combinations of asp and pin value, but could not get what I wanted.. Thank you in advance for your help Sebastien ______________________________________________ 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.
1 day later
Thanks to all the people who answer my question. It is know clear to know how to produce a square shape graph... but I guess there is no easy way to force the x and the y axis to have the same limits. *Sebastien*
Rodrigo Aluizio wrote:
Hi Sebastien, take a look at the par(pty='s') argument. Maybe its can solve your issue. Best wishes. Rodrigo. -----Mensagem original----- De: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] Em nome de Sebastien Bihorel Enviada em: segunda-feira, 20 de abril de 2009 12:26 Para: R-help Assunto: [R] How to force axis to have the same range Dear R-users, I am trying to produce (standard and trellis) scatterplots which use the same range of the x and y axes. In addition, I would like the plots to be physically square. Is there one or more specific argument(s) to plot and xyplot what would do that? I have looked at various combinations of asp and pin value, but could not get what I wanted.. Thank you in advance for your help Sebastien
______________________________________________ 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.
On 4/22/09, Sebastien Bihorel <Sebastien.Bihorel at cognigencorp.com> wrote:
Thanks to all the people who answer my question. It is know clear to know how to produce a square shape graph... but I guess there is no easy way to force the x and the y axis to have the same limits.
If you mean the general case where you don't want to specify xlim and
ylim explicitly, then in lattice you can use
xyplot(...
prepanel = function(x, y, ...) {
rng <- range(x, y, finite = TRUE)
list(xlim = rng, ylim = rng)
})
-Deepayan
For variables named my.x and my.y try:
plot( my.x, my.y, xlim=range(my.x,my.y), ylim=range(my.x,my.y) )
If all you want is to have the same range of values on both the x and y axes.
Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.snow at imail.org 801.408.8111 > -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- > project.org] On Behalf Of Sebastien Bihorel > Sent: Wednesday, April 22, 2009 6:26 AM > To: Rodrigo Aluizio > Cc: R Help; 'Sebastien Bihorel' > Subject: Re: [R] RES: How to force axis to have the same range > > Thanks to all the people who answer my question. It is know clear to > know how to produce a square shape graph... but I guess there is no > easy > way to force the x and the y axis to have the same limits. > > *Sebastien* > > > Rodrigo Aluizio wrote: > > Hi Sebastien, take a look at the par(pty='s') argument. Maybe its can > solve > > your issue. > > > > Best wishes. > > > > Rodrigo. > > > > -----Mensagem original----- > > De: r-help-bounces at r-project.org [mailto:r-help-bounces at r- > project.org] Em > > nome de Sebastien Bihorel > > Enviada em: segunda-feira, 20 de abril de 2009 12:26 > > Para: R-help > > Assunto: [R] How to force axis to have the same range > > > > Dear R-users, > > > > I am trying to produce (standard and trellis) scatterplots which use > the > > same range of the x and y axes. In addition, I would like the plots > to > > be physically square. Is there one or more specific argument(s) to > plot > > and xyplot what would do that? I have looked at various combinations > of > > asp and pin value, but could not get what I wanted.. > > > > Thank you in advance for your help > > > > Sebastien > > > > ______________________________________________ > > 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. > > > > > > ______________________________________________ > 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.
1 day later
Thanks to Greg and Deepayan for their answers. *Sebastien Bihorel, PharmD, PhD* PKPD Scientist Cognigen Corp Email: sebastien.bihorel at cognigencorp.com <mailto:sebastien.bihorel at cognigencorp.com> Phone: (716) 633-3463 ext. 323
Greg Snow wrote:
For variables named my.x and my.y try:
plot( my.x, my.y, xlim=range(my.x,my.y), ylim=range(my.x,my.y) )
If all you want is to have the same range of values on both the x and y axes.