Giter VIP home page Giter VIP logo

Comments (4)

brianwdavis avatar brianwdavis commented on June 10, 2024

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")

image

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.

coatless avatar coatless commented on June 10, 2024

@brianwdavis thanks. To keep dependencies low, I may write a second package that hooks into cetcolor with the aforementioned ggplot2 support.

from cetcolor.

coatless avatar coatless commented on June 10, 2024

@brianwdavis, I forgot to ask, when do you need this by?

from cetcolor.

brianwdavis avatar brianwdavis commented on June 10, 2024

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 photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.