[R] problem with lattice tiff or bitmap: character size and color

Einar Árnason einararn at hi.is
Sun Apr 5 14:29:28 CEST 2009


Hi all,

I am trying to make tiff files  of lattice plots at a resolution greater
than 300 dpi required by a journal (PLoS ONE). I have tried both the tiff
and bitmap functions. tiff keeps panel colors but reduces axes and tick
labels so they are nearly invisible. bitmap maintains correct label size
but only produces greyscale. Regular plots work fine with tiff; the
problem is only with lattice plots.

How can I keep the right sizes using tiff or, alternatively, how can I get
bitmap to produce colors?

I have made this test function using an xyplot example to demonstrate the
problem.

`test` <- function(tiff=F, bitmap=F)
  {
### requires states
### states <- data.frame(state.x77, state.name = dimnames(state.x77)[[1]],
### state.region = state.region)
    if(bitmap)
      bitmap("bitmaptest.tiff", width=17.15, height=17.15, units="cm",
res=1200, pointsize=10, type="tifflzw",bg="white")
    if(tiff)
      tiff(file="tifftest.tiff",width=17.15,height=17.15,units="cm",
res=1200, pointsize=10, compression = "lzw")
###      tiff(file="tifftest.tiff",width=17.15,height=17.15,units="cm",
###res=72, pointsize=10, compression = "lzw")
  plot(xyplot(Murder ~ Population | state.region, data = states,
            groups = state.name,
            panel = function(x, y, subscripts, groups)
            ltext(x = x, y = y, label = groups[subscripts], cex=0.5,
                  fontfamily = "HersheySans")))
    if(bitmap)
      dev.off()
    if(tiff)
      dev.off()
}


> R.Version()
$platform
[1] "x86_64-redhat-linux-gnu"

$arch
[1] "x86_64"

$os
[1] "linux-gnu"

$system
[1] "x86_64, linux-gnu"

$status
[1] ""

$major
[1] "2"

$minor
[1] "8.1"

$year
[1] "2008"

$month
[1] "12"

$day
[1] "22"

$`svn rev`
[1] "47281"

$language
[1] "R"

$version.string
[1] "R version 2.8.1 (2008-12-22)"



More information about the R-help mailing list