[R] pointsize in png graphics
Kevin Bartz
kbartz at loyaltymatrix.com
Thu Sep 30 16:53:04 CEST 2004
Jan.Kleinn at partnerre.com wrote:
> Dear all,
>
> I'm trying to produce 2 png files, one consisting of an image plot and a
> color-table (also an image plot) and the other one consisting of 4 image
> plots and a color table. I'd like the color table to be exactly the same.
> The way I proceded is the following:
>
> for one plot and the color-table
> png(file = png.file, width = 650, height = 800, pointsize = 16)
> layout(matrix(c(1, 2), ncol = 2, nrow = 1, byrow = T),
> widths = c(6, 1), heights = 1)
> par(mar = c(0.2, 0.2, 0.2, 0.2), mgp = c(2, 1, 0), las = 0)
> ...
> dev.off()
>
> for 4 plots and the color-table
> png(file = png.file, width = 650, height = 800, pointsize = 16)
> layout(matrix(c(1, 2, 5, 3, 4, 5), ncol = 3, nrow = 2, byrow = T),
> widths = c(3, 3, 1), heights = c(1, 1))
> par(mar = c(0.2, 0.2, 0.2, 0.2), mgp = c(2, 1, 0), las = 0)
> ...
> dev.off()
>
> The only difference is the layout of the plot. The outcome though is
> completely different. It seems that the definition of the size of one point
> is different in the two plots as the graphics with 4 plots and color table
> has smaller fonts and smaller margins. What do I have to do to be sure the
> size of the fonts is the same in two different png graphcis of exactly the
> same size when the pointsize is the same?
>
> I'm working with Windows XP and tried both running the R script as a batch
> job and running it within Emacs with ESS.
>
>
>>version
>
> _
> platform i386-pc-mingw32
> arch i386
> os mingw32
> system i386, mingw32
> status
> major 1
> minor 9.1
> year 2004
> month 06
> day 21
> language R
>
> Many thanks in advance and best regards, Jan:-)
>
> ______________________________________________
> R-help at 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
>
Hi Jan,
Generally, I've found it very undesirable to set pointsize when calling
a graphics device. Instead, I set the cex parameter, either globally
through "par" or for each individual plot. If you don't tweak the
defaults, then cex effectively works in picas, so you can divide your
desired point size by 12 to come up with the right value of cex. Why
don't you give that a try and let me know how it turns out?
Also, are you sure that you managed to run that code as a batched
script? png() is one of the graphics devices that doesn't work in batch.
To get batched pngs, I typically have to use bitmap(type = "png16m", ...).
Kevin
More information about the R-help
mailing list