[R] Trellis margins settings so that they are like a base graphic with no figure region when printed to png file?

Mark Heckmann mark.heckmann at gmx.de
Fri Dec 12 19:30:48 CET 2008


  
Dear R-experts,

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 this was easy:

  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:

    myHistogram <- 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.

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