Giter VIP home page Giter VIP logo

Comments (1)

teunbrand avatar teunbrand commented on June 2, 2024 1

This has been on my mind as well to make the interface between scales and palettes somewhat smoother.
Your first example can be replaced with discrete_scale("colour", palette = scales::pal_hue()), but this is not so much the case for the continuous examples.

For this to happen, I think {scales} needs to start describing palette functions more so that some properties are easily queried.
Useful properties to know about palettes are:

  • Is it continuous, i.e. does it accept values in the (0, 1) range.
  • Is it discrete, i.e. does it accept n values.
  • If discrete, what is the maximum n it will accept?
  • Do they have built-in NA handlers (e.g. via scales::colour_ramp())?

If we know this, we can automatically expand discrete palettes to continuous ones by using e.g. colour_ramp(discrete_pal()(n_max)), or discretise continuous palettes by using continuous_pal()(seq(0, 1, length.out = n).

from ggplot2.

Related Issues (20)

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.