[R] pointsize in png graphics

2004-09-30 Thread Jan . Kleinn
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
major1
minor9.1
year 2004
month06
day  21
language R

Many thanks in advance and best regards, Jan:-)

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] pointsize in png graphics

2004-09-30 Thread Kevin Bartz
[EMAIL PROTECTED] 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
major1
minor9.1
year 2004
month06
day  21
language R
Many thanks in advance and best regards, Jan:-)
__
[EMAIL PROTECTED] 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
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] pointsize in png graphics

2004-09-30 Thread Paul Murrell
Hi
[EMAIL PROTECTED] 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.

I think the problem is that R is trying to think for you.  R 
automatically reduces text size when there are more than three plots (or 
more than three cells in a layout) on a page.  Below are two suggestions 
for making the two layouts the same:

# dummy image plot
dummyplot - function(col) {
  plot.new()
  usr - par(usr)
  rect(usr[1], usr[3], usr[2], usr[4], col=col)
}
# original problem
x11()
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)
dummyplot(orange)
dummyplot(blue)
x11()
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)
dummyplot(red)
dummyplot(yellow)
dummyplot(pink)
dummyplot(violet)
dummyplot(blue)
# solution 1: make second layout same as first
# leave first page alone
# revert auto cex decrease on second page
x11()
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)
dummyplot(orange)
dummyplot(blue)
x11()
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,
### CHANGES HERE
cex=1.5, mex=0.66)
dummyplot(red)
dummyplot(yellow)
dummyplot(pink)
dummyplot(violet)
dummyplot(blue)
# solution 2: make first layout same as second
# make same number of columns/rows in first layout
# leave second page alone
x11()
layout(### CHANGES HERE
   matrix(c(1, 1, 2, 1, 1, 2), ncol = 3, nrow = 2, 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)
dummyplot(orange)
dummyplot(blue)
x11()
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)
dummyplot(red)
dummyplot(yellow)
dummyplot(pink)
dummyplot(violet)
dummyplot(blue)
Paul
--
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
[EMAIL PROTECTED]
http://www.stat.auckland.ac.nz/~paul/
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html