Mercutio Florid
2013-Nov-19 08:56 UTC
[R] can par()$pin be used to guarantee equal horizontal and vertical image lengths?
Today at 10:03 AM I use several different versions of R, including RGui on Windows and rstudio on Linux. In all cases, I use graphical commands, such as image(). image() displays rectangles, but I want to be able to guarantee that the heights of those rectangles will always equal the widths. Typically, the rectangles come out with notable asymmetries. Thus, if I need to draw a perfect circle with square pixels, I usually get a squashed ellipse with oblong pixels. I had hoped that par()$pin would be the answer, but I can't seem to set it properly. For example:> par()$pin[1] 4.416111 1.685556> source('~/.active-rstudio-document') > par()$pin<-c(4,4)Error in par()$pin <- c(4, 4) : invalid (NULL) left side of assignment> str(par()$pin)num [1:2] 4.46 2.82> par()$pin[2]<-par()$pin[1]Error in par()$pin[2] <- par()$pin[1] : invalid (NULL) left side of assignment I have experimented with other commands, and I don't need to continue to use image() if some other command would be more suitable. Thanks. [[alternative HTML version deleted]]
Thomas Stewart
2013-Nov-21 06:43 UTC
[R] can par()$pin be used to guarantee equal horizontal and vertical image lengths?
How about using the asp option? For example, A <- matrix(rnorm(200),20) image(A, asp=ncol(A)/nrow(A)) -tgs On Tue, Nov 19, 2013 at 3:56 AM, Mercutio Florid <floridmercutio@yahoo.com>wrote:> > Today at 10:03 AM > I use several different versions of R, including RGui on Windows and > rstudio on Linux. In all cases, I use graphical commands, such as > image(). > > image() displays rectangles, but I want to be able to > guarantee that the heights of those rectangles will always equal the > widths. Typically, the rectangles come out with notable asymmetries. > > Thus, if I need to draw a perfect circle with square pixels, I usually get > a squashed ellipse with oblong pixels. > > I had hoped that par()$pin would be the answer, but I can't seem to set it > properly. For example: > > par()$pin > [1] 4.416111 1.685556 > > source('~/.active-rstudio-document') > > par()$pin<-c(4,4) > Error in par()$pin <- c(4, 4) : invalid (NULL) left side of assignment > > str(par()$pin) > num [1:2] 4.46 2.82 > > par()$pin[2]<-par()$pin[1] > Error in par()$pin[2] <- par()$pin[1] : > invalid (NULL) left side of assignment > > I > have experimented with other commands, and I don't need to continue to > use image() if some other command would be more suitable. > > Thanks. > [[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]]