Re: [R] Adding units to levelplot's colorkey
Thanks. On 11/23/11 2:20 AM, Deepayan Sarkar wrote: On Tue, Nov 15, 2011 at 6:53 PM, Carlisle Thacker carlisle.thac...@noaa.gov wrote: Sorry that I was not clear. I was asking how to add annotation to levelplot's colorkey, not the levelplot itself. The only entry I can find from the help pages is via its labels. Googling did yield this: draw.colorkey() doesn't support a title for the legend. So I presume there is also no support for any other annotation. That is correct. Note that having support for more annotation is not technically difficult, but it's not clear what a good design would be. For the purpose you describe, I typically do something like levelplot(volcano, colorkey = list(space = top), main = Height (cm)) But I don't know how to do this nicely with a vertical color key. -Deepayan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Adding units to levelplot's colorkey
Here is an example with what I've been able to manage for a vertical colorkey: library(lattice)# make levelplot available library(openair) # make drawOpenKey available # construct data x = 1:10 y = rep(x,rep(10,10)) x = rep(x,rep(10)) z = x+y # in centimeters # try work-around, attaching annotation to 1st tick label levelplot(z~x*y, colorkey=list(at=1:21,labels=c(1\n\n(cm),as.character(2:21 # \n works but 1 is raised while (cm) is lowered # try work-around, attaching annotation as 1st tick label levelplot(z~x*y, colorkey=list(at=1:21,labels=c((cm),as.character(2:20),))) # not bad, best so far # try work-around, attaching annotation as 0th tick label levelplot(z~x*y, colorkey=list(at=0:21,labels=c((cm),as.character(1:20),))) # not better, but OK # change colors using best so far levelplot(z~x*y, colorkey=list(at=1:21,labels=c((cm),as.character(2:20),),col=rainbow(200)[1:180]), col.regions= rainbow(200)[1:180]) # rainbow had red at both ends, so used [1:180] # start labels with additional spaces to line them up with units levelplot(z~x*y, colorkey=list(at=1:21,labels=c((cm),paste( ,as.character(2:20)),),col=rainbow(200)[1:180]), col.regions= rainbow(200)[1:180]) # looks good Would be nice to have better control. On 11/23/11 2:20 AM, Deepayan Sarkar wrote: On Tue, Nov 15, 2011 at 6:53 PM, Carlisle Thacker carlisle.thac...@noaa.gov wrote: Sorry that I was not clear. I was asking how to add annotation to levelplot's colorkey, not the levelplot itself. The only entry I can find from the help pages is via its labels. Googling did yield this: draw.colorkey() doesn't support a title for the legend. So I presume there is also no support for any other annotation. That is correct. Note that having support for more annotation is not technically difficult, but it's not clear what a good design would be. For the purpose you describe, I typically do something like levelplot(volcano, colorkey = list(space = top), main = Height (cm)) But I don't know how to do this nicely with a vertical color key. -Deepayan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Adding units to levelplot's colorkey
On Tue, Nov 15, 2011 at 6:53 PM, Carlisle Thacker carlisle.thac...@noaa.gov wrote: Sorry that I was not clear. I was asking how to add annotation to levelplot's colorkey, not the levelplot itself. The only entry I can find from the help pages is via its labels. Googling did yield this: draw.colorkey() doesn't support a title for the legend. So I presume there is also no support for any other annotation. That is correct. Note that having support for more annotation is not technically difficult, but it's not clear what a good design would be. For the purpose you describe, I typically do something like levelplot(volcano, colorkey = list(space = top), main = Height (cm)) But I don't know how to do this nicely with a vertical color key. -Deepayan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Adding units to levelplot's colorkey
On Nov 14, 2011, at 7:20 PM, Carlisle Thacker wrote: Thanks, Dennis. Yes, I can do that, but that locks the physical units to locations of the labels. I had hoped that there might be something a bit more flexible, like a subtitle or more general text. If you would take the time to describe what you wanted you would save everybody's time, yours and ours. I'm sure that levelplot's help page refers you to the xyplot help page for details on key parameters. So here are a few of the parameter it makes available but the entirelist takes up several pages and is not reproduced here: title String or expression giving a title for the key. cex.title Zoom factor for the title. lines.title The amount of vertical space to be occupied by the title in lines (in multiples of itself). Defaults to 2. -- David. Carlisle On 11/14/11 6:03 PM, Dennis Murphy wrote: You don't show code or a reproducible example, so I guess you want a general answer. Use the draw.colorkey() function inside the levelplot() call. It takes an argument key =, which accepts a list of arguments, including space, col, at, labels, tick.number, width and height (see p. 155 of the Lattice book). More specifically, the labels argument also accepts a list of values, with components at, labels, cex, col, font, fontface and fontfamily. You could attach the units as labels with a combination of at = and labels = inside the (outer) labels argument, something like myAt- c(1, 3, 5, 7, 9) myLab- paste(myAt, 'cm') levelplot( ... draw.colorkey(key = list(labels = list(at = myAt, labels = myLab)), ...) If that doesn't work, then please provide a reproducible example. HTH, Dennis On Mon, Nov 14, 2011 at 12:34 PM, Carlisle Thacker carlisle.thac...@noaa.gov wrote: How to add units (e.g. cm) to the color key of a lattice levelplot? The plots looks fantastic, but it would be nice to indicate somewhere near the end of the color key that the values associated with its colors are in centimeters or some other physical units. The only thing I find is the possibility to specify the labels so that one explicitly includes the units. That leaves little flexibility for positioning where this information appears. Is there a better way? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Adding units to levelplot's colorkey
On Nov 15, 2011, at 8:23 AM, Carlisle Thacker wrote: Sorry that I was not clear. I was asking how to add annotation to levelplot's colorkey, not the levelplot itself. The only entry I can find from the help pages is via its labels. Googling did yield this: draw.colorkey() doesn't support a title for the legend. So I presume there is also no support for any other annotation. You are right. I failed to test my presumptions. Apologies extended. -- David. Thanks for your assistance. On 11/15/11 7:54 AM, David Winsemius wrote: On Nov 14, 2011, at 7:20 PM, Carlisle Thacker wrote: Thanks, Dennis. Yes, I can do that, but that locks the physical units to locations of the labels. I had hoped that there might be something a bit more flexible, like a subtitle or more general text. If you would take the time to describe what you wanted you would save everybody's time, yours and ours. I'm sure that levelplot's help page refers you to the xyplot help page for details on key parameters. So here are a few of the parameter it makes available but the entirelist takes up several pages and is not reproduced here: title String or expression giving a title for the key. cex.title Zoom factor for the title. lines.title The amount of vertical space to be occupied by the title in lines (in multiples of itself). Defaults to 2. David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Adding units to levelplot's colorkey
Sorry that I was not clear. I was asking how to add annotation to levelplot's colorkey, not the levelplot itself. The only entry I can find from the help pages is via its labels. Googling did yield this: draw.colorkey() doesn't support a title for the legend. So I presume there is also no support for any other annotation. Thanks for your assistance. On 11/15/11 7:54 AM, David Winsemius wrote: On Nov 14, 2011, at 7:20 PM, Carlisle Thacker wrote: Thanks, Dennis. Yes, I can do that, but that locks the physical units to locations of the labels. I had hoped that there might be something a bit more flexible, like a subtitle or more general text. If you would take the time to describe what you wanted you would save everybody's time, yours and ours. I'm sure that levelplot's help page refers you to the xyplot help page for details on key parameters. So here are a few of the parameter it makes available but the entirelist takes up several pages and is not reproduced here: title String or expression giving a title for the key. cex.title Zoom factor for the title. lines.title The amount of vertical space to be occupied by the title in lines (in multiples of itself). Defaults to 2. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Adding units to levelplot's colorkey
How to add units (e.g. cm) to the color key of a lattice levelplot? The plots looks fantastic, but it would be nice to indicate somewhere near the end of the color key that the values associated with its colors are in centimeters or some other physical units. The only thing I find is the possibility to specify the labels so that one explicitly includes the units. That leaves little flexibility for positioning where this information appears. Is there a better way? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Adding units to levelplot's colorkey
You don't show code or a reproducible example, so I guess you want a general answer. Use the draw.colorkey() function inside the levelplot() call. It takes an argument key =, which accepts a list of arguments, including space, col, at, labels, tick.number, width and height (see p. 155 of the Lattice book). More specifically, the labels argument also accepts a list of values, with components at, labels, cex, col, font, fontface and fontfamily. You could attach the units as labels with a combination of at = and labels = inside the (outer) labels argument, something like myAt - c(1, 3, 5, 7, 9) myLab - paste(myAt, 'cm') levelplot( ... draw.colorkey(key = list(labels = list(at = myAt, labels = myLab)), ...) If that doesn't work, then please provide a reproducible example. HTH, Dennis On Mon, Nov 14, 2011 at 12:34 PM, Carlisle Thacker carlisle.thac...@noaa.gov wrote: How to add units (e.g. cm) to the color key of a lattice levelplot? The plots looks fantastic, but it would be nice to indicate somewhere near the end of the color key that the values associated with its colors are in centimeters or some other physical units. The only thing I find is the possibility to specify the labels so that one explicitly includes the units. That leaves little flexibility for positioning where this information appears. Is there a better way? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Adding units to levelplot's colorkey
Thanks, Dennis. Yes, I can do that, but that locks the physical units to locations of the labels. I had hoped that there might be something a bit more flexible, like a subtitle or more general text. Carlisle On 11/14/11 6:03 PM, Dennis Murphy wrote: You don't show code or a reproducible example, so I guess you want a general answer. Use the draw.colorkey() function inside the levelplot() call. It takes an argument key =, which accepts a list of arguments, including space, col, at, labels, tick.number, width and height (see p. 155 of the Lattice book). More specifically, the labels argument also accepts a list of values, with components at, labels, cex, col, font, fontface and fontfamily. You could attach the units as labels with a combination of at = and labels = inside the (outer) labels argument, something like myAt- c(1, 3, 5, 7, 9) myLab- paste(myAt, 'cm') levelplot( ... draw.colorkey(key = list(labels = list(at = myAt, labels = myLab)), ...) If that doesn't work, then please provide a reproducible example. HTH, Dennis On Mon, Nov 14, 2011 at 12:34 PM, Carlisle Thacker carlisle.thac...@noaa.gov wrote: How to add units (e.g. cm) to the color key of a lattice levelplot? The plots looks fantastic, but it would be nice to indicate somewhere near the end of the color key that the values associated with its colors are in centimeters or some other physical units. The only thing I find is the possibility to specify the labels so that one explicitly includes the units. That leaves little flexibility for positioning where this information appears. Is there a better way? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.