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

support reversed color schemes #277

Open
gwarmstrong opened this issue Feb 26, 2020 · 3 comments
Open

support reversed color schemes #277

gwarmstrong opened this issue Feb 26, 2020 · 3 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@gwarmstrong
Copy link
Member

It would be awesome if color schemes could be inverted, e.g.,

Screen Shot 2020-02-26 at 10 32 53 AM

from the red sea example. In the picture, I am using redblue color scheme, but due to ordering, colder temperatures are red and warmer temperatures are blue, which is a little counter-intuitive and it would theoretically be nice to display the legend with the opposite color ordering. There is no bluered color scheme in vega-lite, so in order to get the color scheme inverted, you have to invert the upper and lower bound of the domain, something like adding domain=[1, 0] to the scale call:

scale=alt.Scale(paddingOuter=1, paddingInner=0, rangeStep=1),

I think user-side, this would look something like having a checkbox titled Invert quantitative color scheme, that you can use to apply the domain change.

This issue vega/altair#1068 may be informative

@fedarko fedarko added enhancement New feature or request good first issue Good for newcomers labels Feb 26, 2020
@fedarko
Copy link
Collaborator

fedarko commented Feb 26, 2020

Reading over the linked Altair issue, this should be doable by just adding in a "sort" attribute to the Vega-Lite spec for the sample plot then regenerating it. This is in principle the same way all of the other sample plot controls work -- the main hassle here will be just doing the copypasta to make sure this is tested, etc.

@gwarmstrong
Copy link
Member Author

My understanding of the Altair issue was that ‘domain=[1, 0]’ reversed the color scale, whereas “sort” inverts the quantitative values (e.g., blue remains “top” of color scale, but now 30 is the lowest value and 20 is the highest value). So the difference is in whether your color scale or your values are inverted.

To me it makes more sense to invert the color scale if that’s what you want, as opposed to the sorting your values around the color scale you want. That being said, I think each approach has different implications for future extensibility.

@fedarko
Copy link
Collaborator

fedarko commented Feb 26, 2020

Gotcha, thanks! Serves me right for not reading closely enough :) I think changing the domain in the Vega-Lite spec should be possible in JavaScript.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants