[R] 'symbols' not drawing correctly in the 'y' dimension
Sarah Goslee
sarah.goslee at gmail.com
Thu May 9 23:11:58 CEST 2013
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
More information about the R-help
mailing list