0

I'm trying to put text outside of a graphical legend using lattice, but it's proving a pain. It's a scatterplot that is sorted along a coloured scale by another variable. The legend appears fine, but unfortunately it doesn't have a text label (the easiest part). I've tried title (for legend), text, Mtext, panel.text which only puts the text within the panel. Furthermore, everywhere I try and put label or text within the legend code doesn't seem to work.

xyplot(calcona$Mid.depth ~ calcona$bits, 
    data=calcona, groups = color, col="black", 
    panel = function (x, y, groups, ..., subscripts) 
    { 
      fill<-groups[subscripts] 
      panel.grid(h=-1, v=-1) 
      panel.xyplot(x, y, pch=21, fill=fill, ...) 
    }, 
    legend= 
      list(right= #I believe the code needs to go here somewhere. 
             list(title="text here doesn't work", fun=draw.colorkey, 
                  args=list(key=list(col=heat.colors, 
                                     at = caex.breaks), 
                            draw=FALSE))), 
    ylim=(rev(range(0:100))), 
    xlim = range(0:7), ylab = "Depth (cm)", 
    xlab = "SEM (%)", 
    main = list( label = 
                   "SEM", cex=1)) 
John Paul
  • 12,196
  • 6
  • 55
  • 75
  • Please provide a reproducible example. http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – Johan Larsson Mar 03 '17 at 08:57
  • Possible duplicate of [How to add a title to legend scale using levelplot in R?](http://stackoverflow.com/questions/24528527/how-to-add-a-title-to-legend-scale-using-levelplot-in-r) – Johan Larsson Mar 03 '17 at 10:23

0 Answers0