Skip to content

bitmap .tif in colors

6 messages · Lauri Nikkinen, Uwe Ligges, Brian Ripley

#
Hello,

How to produce .tif graphic in colors using bitmap function?

e.g this produces figure in grayscale

bitmap(file="volc.tif", type = "tifflzw", res = 300)
image(t(volcano)[ncol(volcano):1,])
dev.off()

I'm using Windows XP and ghostscript.
$platform
[1] "i386-pc-mingw32"

$arch
[1] "i386"

$os
[1] "mingw32"

$system
[1] "i386, mingw32"

$status
[1] ""

$major
[1] "2"

$minor
[1] "7.1"

$year
[1] "2008"

$month
[1] "06"

$day
[1] "23"

$`svn rev`
[1] "45970"

$language
[1] "R"

$version.string
[1] "R version 2.7.1 (2008-06-23)"
#
Lauri Nikkinen wrote:
Why not upgrade R and use the tiff() device?

Uwe Ligges
#
Thanks. I upgraded to R 2.8.1 and tried

tiff(filename = "volc.tif", width=600, height=400, compression =
"none", bg = "white", res = 300)
image(t(volcano)[ncol(volcano):1,])
dev.off()

but this produces error

Error in plot.new() : figure margins too large

How this should be modified to produce a decent-sized graph?

Regards,
Lauri

2009/2/18 Uwe Ligges <ligges at statistik.tu-dortmund.de>:
#
Lauri Nikkinen wrote:
Try a somewhat lower resolution or reduce the margins:
par(mar=c(....))

Uwe Ligges
#
On Wed, 18 Feb 2009, Lauri Nikkinen wrote:

            
Well, thae is a 2" by 1.3" image, so the pointsize is way too large. 
Increase the dimensions or decrease the resolution or decreaase the 
pointsize.

(As a warning, there was a 'grid' bug that affected some versions of 
tiff, png etc in 2.8.0 and 2.8.1 when plotting lattice plots at 
non-default resolutions.  The NEWS item is

     o	grid-based plots no longer reset the base text size to the
 	default 96dpi in cairo-based bitmap devices.

for 2.8.1 patched.  But that produces too small not too large text.)

  
    
#
Thanks Prof Ripley, now I understood.

tiff(filename = "volc.tif", width=600, height=400, compression =
"none", bg = "white", res = 300, pointsize=3)
par(mar=c(3,3,2,2), cex=1)
image(t(volcano)[ncol(volcano):1,], xaxt="n", yaxt="n")
axis(1, at=seq(0, 1, 0.1), cex.axis=0.8, tick=T)
axis(2, at=seq(0, 1, 0.1), cex.axis=0.8, tick=T)
dev.off()

Regards,
Lauri

2009/2/18 Prof Brian Ripley <ripley at stats.ox.ac.uk>: