[R] png scaling problem

Marc Schwartz (via MN) mschwartz at mn.rr.com
Thu Sep 1 22:53:15 CEST 2005

On Thu, 2005-09-01 at 21:51 +0200, Knut Krueger wrote:
> scaling<-4
> xywidth<-480
> resolution<-150
> png(filename = "c:/r/anschluss/plots/4.png", width = xywidth*scaling, 
> height = xywidth*scaling,pointsize = 12, bg = "white", res = 
> resolution*scaling)
> ......
> barplot(xrow,col = barcolors,cex.axis=scaling, ylab="mean time till attachment in sec",cex.lab=1.2*scaling) 
> I tried to scale the barplot but there is one strange result:
> scaling=1
> http://biostatistic.de/temp/1.png    --- the ylab is ok
> scaling=2
> http://biostatistic.de/temp/2.png    --- the ylab is not ok
> scaling=4
> http://biostatistic.de/temp/4.png    --- the ylab is terrible
> is there any better solution to scale the resolution and the width/height?
> with regards
> Knut

Probably a better first question is, why are you using a bitmapped
graphics format if you need the image to be re-scaled? In general,
bitmapped graphics do not resize well, though if you have a specific
need and know a target image size, you can adjust various parameters to
look decent. Are you going to view these images in a web browser, where
you are concerned with display size and resolution?

>From your e-mail headers it appears you are on Windows. If you need a
re-sizable graphic, use a vector based format such as wmf/emf,
especially if you need the graphics embedded in a Windows application
such as Word or Powerpoint. This is the default format under Windows
when copying and pasting a graphic between applications. You can then,
fairly freely, resize the image in the target application as you may

If you are going to print the graphic directly or include it in a
document for printing (as opposed to just viewing it), then use PDF or
Postscript. The latter in EPS format, can be imported into many Windows
applications like Word, including the generation of a preview image.
However, they don't look good for direct use in presentations (unless
you print to a PS file and then convert to PDF for viewing).

See ?Devices for more information.

With a better idea of how you plan to use the graphic(s), we can offer
more specific recommendations on how to proceed.

Marc Schwartz

More information about the R-help mailing list