Skip to content

Increasing font size in a levelplot graphic

4 messages · Pascal Oettli, Oscar Perpiñan, Thiago V. dos Santos

#
Dear R-SIGgers,

This question is related to the rasterVis package. Please reproduce the following plot:

library(raster)
library(rasterVis)

r1=r2=r3=raster(nr=100, nc=100)
r1[]<-r2[]<-r3[]<-1:ncell(r1)
s<-stack(r1,r2,r3)
levelplot(s)

On my Mac, I think the text size is too small. Increasing picture dimensions won't work - graph size will increase but text still looks small.

So my question arises: how can I increase axis, scale and title font size in a levelplot graphic? I've skimmed over both rasterVis and lattice documentation and haven't found any clues.


Any help appreciated.

Best regards,
Thiago.
#
Hi,

For example:

p.strip <- list(cex=1.5, lines=2, fontface='bold')
ckey <- list(labels=list(cex=1.5, col='magenta'), height=0.5)
x.scale <- list(cex=1, alternating=1, col='red')
y.scale <- list(cex=1, alternating=1, col='blue')

levelplot(s, colorkey=ckey, par.strip.text=p.strip, 
scales=list(x=x.scale, y=y.scale))

HTH,
Pascal
On 26/03/13 12:16, Thiago V. dos Santos wrote:
#
Hi,

On the other hand, perhaps your problem arises when you export the
graphic using large values for width and height without modifying the
resolution.

Try this:

library(raster)
library(rasterVis)

r <- raster()
r <- init(r, runif)

## res=72 if none is provided
png('smallFontSize.png', width=4000, height=4000)
levelplot(r)
dev.off()

png('correctFontSize.png', width=4000, height=4000, res=600)
levelplot(r)
dev.off()


Best,

Oscar.
Pascal Oettli <kridox at ymail.com> writes:

  
    
#
Oscar and Pascal,

Thank you for the suggestions. Both of them solved my problem.

Best,
Thiago.


----- Original Message -----
From: Oscar Perpi??n Lamigueiro <oscar.perpinan at gmail.com>
To: Pascal Oettli <kridox at ymail.com>
Cc: Thiago V. dos Santos <thi_veloso at yahoo.com.br>; R-SIG list <r-sig-geo at r-project.org>
Sent: Tuesday, March 26, 2013 4:40 AM
Subject: Re: [R-sig-Geo] Increasing font size in a levelplot graphic

Hi,

On the other hand, perhaps your problem arises when you export the
graphic using large values for width and height without modifying the
resolution.

Try this:

library(raster)
library(rasterVis)

r <- raster()
r <- init(r, runif)

## res=72 if none is provided
png('smallFontSize.png', width=4000, height=4000)
levelplot(r)
dev.off()

png('correctFontSize.png', width=4000, height=4000, res=600)
levelplot(r)
dev.off()


Best,

Oscar.
Pascal Oettli <kridox at ymail.com> writes: