Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancing color gradient support #3

Closed
6 of 19 tasks
mkborregaard opened this issue Oct 24, 2016 · 5 comments
Closed
6 of 19 tasks

Enhancing color gradient support #3

mkborregaard opened this issue Oct 24, 2016 · 5 comments

Comments

@mkborregaard
Copy link
Member

mkborregaard commented Oct 24, 2016

I suggest enhancing the interface for color gradients. I will try to implement this myself, so this issue is to discuss the applicability and the interface.

The suggested interface is a magic attribute (color?) with the following elements:

  • color : the name of the gradient, e.g. :magma, but also offers
    • :default : the default value, probably equal to :sequential
    • :sequential : a sequential gradient, such as :magma
    • :diverging : a diverging gradient, such as :redsblues, e.g. used when the color variable is a standard variation
    • :dark : or something else - this is an example of other defaults that may be implemented
  • collection: the gradient collection to look in; see issue Using color collections for gradients #4
  • clim : the current clim argument but with extra keywords for common specifications
    • :max_0 : clims are [minimum(x), 0], where x is the vector of values for the colors
    • :min_0 : clims are [0, maximum(x)]
    • :center_0: clims are [-y, y]; y = maximum(abs([extrema(x)...]))
  • gradtype : one of
    • :stretched : the current default, choose colors from a continuous gradient
    • :equal_interval : divide the numerical gradient into classesnumber of bins (makes it easier to read values from plots). The default when classes is an integer
    • :classified : a common synonym for :equal_interval
    • :quantiles : divide x into classes bins with the same number of observations in each
    • :custom : rarely specified directly, but the default when classes is passed a vector. Useful for e.g. classes = [-2, 1, 0, 1, 2] when the color reflects a standard deviation (or other standardized measure)
  • classes : can take either
    • an Int specifying the number of bins for :equal_interval and :quantiles
    • a Vector{T <: Number} specifying custom break points for the color scales. If gradtype is :quantiles this may be a vector of percentile values (e.g. classes = [0.025, 0.5, 0.975])

This interface would allow the users to use color much more succinctly and powerfully for scientific graphing, choropleths etc.

Note that the :color keyword is currently used to refer to both colors and gradients - with @oxinabox very increased number of named colours it may be necessary to rename to avoid confusion?

@mkborregaard
Copy link
Member Author

To implement this, it would be great if someone could direct me to

  1. An example of how magic arguments are implemented.
  2. How the color bars are communicated to the backend - how much fine-grained control is there for these in Plots?
  3. Should some of this be in Plots rather than in PlotUtils?

Thanks.

@funnell
Copy link

funnell commented Jul 30, 2018

@mkborregaard I wouldn't mind tinkering with gradtype if you can give some pointers on how to get started. My motivation is eventually getting heatmaps with categorical colormaps.

@mkborregaard
Copy link
Member Author

Hey that sounds great. Do you mean tinkering with cgrad? One way could have a categorical_cgrad type (or a subtype from a common abstract type with cgrad) that would use its values field to delimit the categories, just lookup and return the right color?

@mkborregaard
Copy link
Member Author

Relevant: JuliaPlots/Plots.jl#383

@mkborregaard
Copy link
Member Author

@daschw I think of this as closed by #87
Amazing, I really love the functionality now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants