I am experiencing some problems with the windows graphics device
and bitmaps. (Everything is done in R 2.3.1 on Windows XP)
As an example, I will use

windows(3,2)
plot(1:10)

It is not a pretty or meaningful graph, but it demonstrates the problem.

savePlot(file="test",type="bmp")

creates a bitmap file of size 303x207 which is somewhat strange
because it seems to use slightly different values for
pixels per inch horizontally and vertically.
(By the way, in my version of R 2.4.0alpha, the bitmap has size
303x206)
The documentation warns that the graphics devices use
pixel per inch values reported by Windows, and that might be unreliable.
In my case,

windows(3,2,xpinch=96)
plot(1:10)
savePlot(file="test",type="bmp")

produces the same image (of the same size) as before, so
Windows seems to report 96 for the pixels per inch value.
The next result surprised me:

windows(3,2,xpinch=96,ypinch=96)
plot(1:10)
savePlot(file="test",type="bmp")

produces a square graphics window and a bitmap file of size
303x303. (In R 2.4.0 alpha the size is 303x302).
In fact, when ypinch is given, height seems to be ignored
and the graphics windows height:width ratio is the
ypinch:xpinch ratio from the call to windows.
windows(10,1,xpinch=96,ypinch=192)

will produce a window which is higher than wide,
which is not what I expected after reading the docs.
(This also is true in R 2.4.0 alpha)

The alternative solution is to use dev2bitmap.

windows(3,2)
plot(1:10)
dev2bitmap(file="test.bmp",type="bmp256",width=3,height=2,res=100)

produces a bitmap of size 300x200 which is exactly what is to
be expected. In this bitmap, however, the leftmost
part of the image displayed in R's graphics window is cut off.

What is the best way of creating bitmaps of a given size
containing the full contents of an R  graphics window?



-- 
Erich Neuwirth, Didactic Center for Computer Science
University of Vienna
Visit our SunSITE at http://sunsite.univie.ac.at
Phone: +43-1-4277-39464 Fax: +43-1-4277-9394

______________________________________________
R-help@stat.math.ethz.ch 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.

Reply via email to