[R] change legend character size in image.plot

David Winsemius dwinsemius at comcast.net
Sun Jul 10 17:04:57 CEST 2011


On Jul 10, 2011, at 6:16 AM, dmeire wrote:

> I'm using the image.plot() function (fields package), but I want to  
> enlarge
> the characters of the legend (as they are too small to be read in a  
> combined
> figure), but there is no way I can find a command to do this. I can  
> enlarge
> the legend bar (with legend.witdh), axis character size (cex.axis)   
> or the
> total legend size (legend.shrink), but not the character size of the  
> legend
> characters itself (and only that). Is it possible to do it in one or  
> another
> way?

Looking at the code, it appears to me that the legend text is written  
with mtext() and that there was no provision made for passing a cex  
parameter to the calls. This appears to be the code that would need to  
be considered and modified:
#------------
     if (!is.null(legend.lab)) {
         legend.args <- list(text = legend.lab, side =  
ifelse(horizontal,
             1, 4), line = legend.mar - 2)
     }
     if (!is.null(legend.args)) {
         do.call(mtext, legend.args)
#---------------

See if creating a modified version of image.plot with an added  
parameter to control cex.legend give you something more useful.

-- 

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list