[R] Shrink Trellis margins settings (when printed to png file)

Mark Heckmann mark.heckmann at gmx.de
Wed Dec 17 17:11:09 CET 2008


Dear R-experts,

I have two problems:

PROBLEM (1)
-----------

I want to produce a very small png file (35 x 18 px) that contains a
histogram without a figure region or margins, only the pure heights. 
In the base graphic system this is simple:

  png(filename = "hist.png", res = 72, width=35, height=18)
        par(mar=c(0,0,0,0), oma=c(0,0,0,0))
        hist(rnorm(100), main="")
  dev.off()

Now I want a grid graphics output as I need the graphic as an object.
I tried several trellis.par settings but I was not able to figure it out
(PROBLEM (1)).

Up to now it looks like this:

library(lattice)
histogram(rnorm(100), xlab="", ylab="", 
                     	 par.settings=list(
axis.line=list(col="transparent"),
xlab.text=list(col="transparent"),
ylab.text=list(col="transparent"),
	
axis.text=list(col="transparent"))
 )

This looks acceptable although I would like smaller margins, that is to say
no margins at all. How cab I achieve that?



PROBLEM (2) 
-----------
Now is, that when it is printed to the png file, the graphic almost consist
of margins only. The main part of the plot shrinks to some tiny points.

I don't know how to change the settings, so I that I get the same as in the
base system.

Does anyone know?


TIA
Mark



More information about the R-help mailing list