Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Allow named layers #723

naught101 opened this Issue · 2 comments

3 participants


Not sure if this is entirely possible, but at the moment, there's no way to apply different scales to different layers. Arguably this is a good thing, because it stops people doing stupid things, but I am of the mind that rope is just a tool, and if some people feel like hanging themselves, that shouldn't stop the rest of us using it for something sensible.

My example: I need to create a figure similar to the one at : multiple model time-series, with an observations time series, and a mean (I actually need to show 3 different means). To do this, at the moment, basically requires giving each dataset (models, observations, means) an extra variable that identifies the data type, so that a colour can be applied to each type. This get really messy once you start needing multiple versions of each figure (ie. some with less data showing, some in greyscale, etc.), because scale_color_manual can only be applied once for a whole graph. If layers could be named, then you could do something like this:

ggplot(models, aes(x=year, y=temp, group=model)) + geom_line()
  + scale_colour_manual(layer='base', values=c('yellow'))
  + geom_line(data=mean, layer='mean') + scale_colour_manual(layer='mean', values=c('red'))
  + geom_line(data=obs, layer='obs') + scale_colour_manual(layer='obs', values=c('black'))

Which would make it really easy and intuitive to remove parts of the graph: just comment out a line - the order of the colour scale doesn't have to change. It also makes it easier to change the colour (or size, or linetype etc.), as the colours are visually mapped to specific datasets in the code (you don't have a single scale_colour_manual(values=c('black', 'red', 'yellow')) that you have to remember the order of).

Does that make sense?


I'd sincerely love this possibility! I just started to use ggplot, however this is something that would be really useful. For example one could also just add +scale_color_hue(l=80) to a certain layer...


This sounds like a great feature, but unfortunately we don't currently have the development bandwidth to support it. If you'd like to submit a pull request that implements this feature, please follow the instructions in the development vignette.

@hadley hadley closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.