[R] Using windows() and jpeg()
Duncan Murdoch
murdoch at stats.uwo.ca
Mon Nov 19 22:54:13 CET 2007
On 19/11/2007 3:09 PM, Irina Burmenko wrote:
> Hello,
>
> I have the following question, which I haven't been able to resolve after days of trying. I used to save my plots as jpegs using the savePlot command. However, that seems to result in lost resolution. So now I'm trying to use the jpeg( ) function, but am having trouble because it seems to be incompatible with the windows (width=, height=) command. It's important for me to be able to specify the window size as well as other parameters. Here is the sample code:
>
> jpeg(filename="myplot.jpg",quality=100)
> windows(width=6.25, height = 3.75)
The jpeg() command should *replace* the windows() command. They both
open new graphics devices. One problem you'll have is that jpeg takes
dimensions in pixels by default; if you want to express it in inches,
you need to say so, and also say what resolution you're assuming. For
example,
jpeg(filename="myplot.jpg",quality=100,width=6.25, height = 3.75,
units="in",res=96)
for 96 dpi resolution.
Duncan Murdoch
> par(pin=c(3.5,1.5),bty="l")
> par(mar=c(2.5,4.1,2.2,10.5))
> x<-c(1,2,3)
> y<-c(4,5,6)
> plot(x,y,"b")
> dev.off()
>
> Using these commands results in an empty plot being saved. However, skipping lines 2-4 saves the graph, but, of course, without the formatting, which is important to me. Any help would be greatly appreciated.
>
> Irina
>
>
> ____________________________________________________________________________________
> Never miss a thing. Make Yahoo your home page.
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
More information about the R-help
mailing list