Damián Cirelli
2013-May-09 20:58 UTC
[R] 'symbols' not drawing correctly in the 'y' dimension
Hello nice R people, I'm struggling with the following code: plot(c(0, 2), c(0, 2)) symbols(1, 1, circles=0.5, add=T, inches=F) symbols(1, 1, squares=1, add=T, inches=F) abline(v=c(0.5, 1.5), lty=2) abline(h=c(0.5, 1.5), lty=2) The a-b lines in the vertical direction coincide perfectly with the borders of both the circle and the square drawn with 'symbols'. However, the a-b lines in the horizontal direction, clearly show that the circle is larger in the y-dimension than radius 0.5; same with the square. Using 'locator', shows the "y-radius" closer to 0.56 Any ideas what could be causing this? I have tried this in 3 different machines,same result. Two are running Ubuntu with the R from the repo, one is running Slackware with R version 2.15.3 compiled from source. Any help much appreciated, Damian
Sarah Goslee
2013-May-09 21:11 UTC
[R] 'symbols' not drawing correctly in the 'y' dimension
Hi, On Thu, May 9, 2013 at 4:58 PM, Dami?n Cirelli <cirelli at ualberta.ca> wrote:> Hello nice R people, > > I'm struggling with the following code: > > plot(c(0, 2), c(0, 2)) > symbols(1, 1, circles=0.5, add=T, inches=F) > symbols(1, 1, squares=1, add=T, inches=F) > abline(v=c(0.5, 1.5), lty=2) > abline(h=c(0.5, 1.5), lty=2) > > The a-b lines in the vertical direction coincide perfectly with the > borders of both the circle and the square drawn with 'symbols'.You need to specifically constrain the aspect ratio to be 1:1: plot(c(0, 2), c(0, 2), asp=1) symbols(1, 1, circles=0.5, add=T, inches=F) symbols(1, 1, squares=1, add=T, inches=F) abline(v=c(0.5, 1.5), lty=2) abline(h=c(0.5, 1.5), lty=2) If you read carefully ?symbols you'll see that by setting inches=FALSE you've specified that user coordinates be used to draw your symbols, but those are not the same in x and y directions unless asp=1 - try resizing the graphics window using your original code and mine, and see what happens.> However, the a-b lines in the horizontal direction, clearly show that > the circle is larger in the y-dimension than radius 0.5; same with the > square. > > Using 'locator', shows the "y-radius" closer to 0.56 > > Any ideas what could be causing this? I have tried this in 3 different > machines,same result. Two are running Ubuntu with the R from the repo, > one is running Slackware with R version 2.15.3 compiled from source. > > Any help much appreciated, > Damian >-- Sarah Goslee http://www.functionaldiversity.org
David Carlson
2013-May-09 21:12 UTC
[R] 'symbols' not drawing correctly in the 'y' dimension
Change the first line to plot(c(0, 2), c(0, 2), asp=1) That will set the aspect ratio between the vertical and horizontal axes to be equal. ------------------------------------- David L Carlson Associate Professor of Anthropology Texas A&M University College Station, TX 77840-4352 -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Dami?n Cirelli Sent: Thursday, May 9, 2013 3:58 PM To: r-help at r-project.org Subject: [R] 'symbols' not drawing correctly in the 'y' dimension Hello nice R people, I'm struggling with the following code: plot(c(0, 2), c(0, 2)) symbols(1, 1, circles=0.5, add=T, inches=F) symbols(1, 1, squares=1, add=T, inches=F) abline(v=c(0.5, 1.5), lty=2) abline(h=c(0.5, 1.5), lty=2) The a-b lines in the vertical direction coincide perfectly with the borders of both the circle and the square drawn with 'symbols'. However, the a-b lines in the horizontal direction, clearly show that the circle is larger in the y-dimension than radius 0.5; same with the square. Using 'locator', shows the "y-radius" closer to 0.56 Any ideas what could be causing this? I have tried this in 3 different machines,same result. Two are running Ubuntu with the R from the repo, one is running Slackware with R version 2.15.3 compiled from source. Any help much appreciated, Damian ______________________________________________ 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.