Comments (4)
I'm writing a package that implements a particular discrete mapping of continuous color maps. In order to provide support for cetcolor
I wrote a thin wrapper:
cet_discrete_pal <- function(...) {
function(n) {
cet_pal(n, ...)
}
}
This returns a function that only takes argument n and returns a vector of colors. That way cet_discrete_pal
behaves just like hue_pal
, brewer_pal
, and viridis_pal
.
You can use it like so:
scale_color_cet <- function(guide = "legend", ...) {
discrete_scale("colour", "cet", guide = guide, palette = cet_discrete_pal(...))
}
And then in use:
ggplot(diamonds, aes(clarity, price, color = clarity)) +
geom_boxplot() +
scale_color_cet(name = "bgy")
Feel free to run with it, but it would be nice if cet_discrete_pal
(or similarly named) would be in a future release, so it could be called in the same way using the discrete_scale
API.
from cetcolor.
@brianwdavis thanks. To keep dependencies low, I may write a second package that hooks into cetcolor
with the aforementioned ggplot2
support.
from cetcolor.
@brianwdavis, I forgot to ask, when do you need this by?
from cetcolor.
I've not really got any timeframe. I will probably just include the cet_discrete_pal()
and deprecate it later if you implement something similar.
from cetcolor.
Related Issues (8)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cetcolor.