karthik / wesanderson

A Wes Anderson color palette for R
Other
1.92k stars 142 forks source link

Update `n` functionality using `colorRampPalette`, and switch order of blues in "Zissou" #1

Closed richardsc closed 10 years ago

richardsc commented 10 years ago

Hi! Nice work putting together this package. I'm an oceanographer (who uses R), and so of course as soon as I saw a link to your repo on Twitter I had to try the "Zissou" palette. I ended up forking your repo, to swap the order of the blues (so it makes more sense for plotting data), and I added colorRampPalette functionality so that the number of colors can be specified easily, beyond the original color levels. zissou_adcp Feel free to follow me @ClarkGRichards to see the ensuing discussion and excitement about trying to use "Zissou" in an oceanographic publication!

karthik commented 10 years ago

Awesome stuff, thanks! I still have plenty more work to do before sending off to CRAN but currently short on time. Would love to see this used in a pub so please ping if I can help speed that up. :ocean:

karthik commented 10 years ago

I'm going to revert back to an older commit temporarily. Package is now broken because no n is passed to colorRampPalette and the call to wes.palette returns a function.

richardsc commented 10 years ago

Yes, sorry, I should have been clearer -- I made that change because it's more consistent with how other colormaps are handled in R (e.g. heat.colors, topo.colors, etc). The n is then handled by passing it into the palette function that wes.palette returns.

Example:

library(wesanderson)
pal <- wes.palette('Zissou')
image(volcano, col=pal(21))

Note that when I use palettes for "image" plots, I usually use the imagep() function in the oce package. For which the default accepts a palette function with or without the n arg.

karthik commented 10 years ago

@richardsc Got it! I rarely use heat maps or topo colors for what I do so I didn't think of the use case. I kept the behavior more consistent with how RColorBrewer works. Try the new fix in the color-fix branch. If should work for all use cases now.

library(devtools)
install_github("karthik/wesanderson", ref = 'color-fix')
library(wesanderson)
pal <- wes.palette(name = "Zissou", type = "continuous")
image(volcano, col = pal(21))

image

If you're happy with this, I'll merge this in with master.

karthik commented 10 years ago

Also please do let me know if you use it in a publication! That would be amazing on so many levels (I'm a terrestrial ecologist but did PhD field work at a marine station. I also currently work with former WHOI people).

richardsc commented 10 years ago

Looks great!