Search code examples
rheatmaplevelplot

filled.contour() in R: labeling axis - cex, las, et al


I want to use filled.contour() to plot some data I have in a matrix.

Everything is perfect until when I import the graphics into my tex file and realize I need to play with the font size for it to be readable in the final document.

Unfortunately, it seems I am unable to tune the parameter cex in filled.contour(), and the same goes for las (I'd like the ylabel to be parallel to the x axis).

Below is a simple example. Although I expected the output to be different in each case, namely the font size, the produced plot is pretty much the same.

Thanks a lot for any help you can give me on this.

    x=1:10
    y=1:10
    z=array(rnorm(100),dim=c(10,10))
    filled.contour(x,y,z)
    filled.contour(x,y,z,xlab='x',ylab='y')
    filled.contour(x,y,z,xlab='x',ylab='y',las=1)
    filled.contour(x,y,z,xlab='x',ylab='y',las=1,cex=2)
    filled.contour(x,y,z,xlab='x',ylab='y',las=1,cex=20)

Solution

  • @QuantIbex is right, though you can also pass through other graphics parameters by specifying in the plot.title, plot.axes, key.title and key.axes arguments.

    This is necessary because the usual graphics parameters are not passed straight through, as described in ?filled.contour:

     ...: additional graphical parameters, currently only passed to
          ‘title()’.
    

    E.g.:

    x=1:10
    y=1:10
    z=array(rnorm(100),dim=c(10,10))
    
    filled.contour(x,y,z,las=0,
      plot.axes={
                  axis(1,cex.axis=2)
                  axis(2,cex.axis=2)
                },
      plot.title={
                  title(xlab="x",cex.lab=2)
                  mtext("y",2,cex=2,line=3,las=1)
      }
    )
    

    enter image description here