-
Notifications
You must be signed in to change notification settings - Fork 71
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
feat: draft allow data_color to take a palette function #192
base: main
Are you sure you want to change the base?
Conversation
I think we ought to support at least hex colors (in all their variations, I think we have regex functions to check for the different representations) and rgba. I'm seeing a lot more of the latter on GitHub mostly in palette repos. Then normalize to hex (I don't believe any of this is lossy). |
Also, I love the surrogate |
OTOH, thinking about the requirement for hex colors in the return of the callable, it would be interesting to have the option to perform the validation as a default, but also have the other option to turn that validation off. Only because you can do some pretty sophisticated things with color in HTML like define gradients and even use animation (and this would definitely fail the proposed validation check). Just more food for thought. |
Re: what else is out there colorcet (seems to also be available via matplotlib. claims to provide better best colormaps for continuous data) |
I think it would be really great to be able to do things like this: https://matplotlib.org/stable/users/explain/colors/colormapnorms.html One could do that by passing a callable that handles both normalization (mapping values to [0,1]) and the color map (numeric -> hex). Maybe we want to allow that, but in general it is nice if these things are separate, so you can outsource one or the other to pre-existing collections of color maps and normalization tools! If you are interested in going that route, it seems like the current domain argument overlaps with what matplotlib normalization is trying to do. Edit: I guess this is similar to transforms in |
This is how I would use matplotlib normalizers + a cmap to get hex values:
I have also attached some example use cases to show off where they can be useful. EDIT: can add the alpha like this, setting the -th column of RGBA color rep and using the
|
This is a very rough draft of what
data_color
might look like, if the palette argument accepted an arbitrary function, mapping values -> hex colors.Example:
Note two important features of the current implementation:
#FFFFFF
)I wonder if there's a nice way to work in polars expressions? The challenge is there's no
this
expression in polars. We could add a surrogate columns, like_this_
etc.. This would allow people to usepl.when(pl.col("_this_") ...).then(...)
. However, it doesn't seem ideal.....An alternative to this might be users using
GT.tab_style
and passing a polars expression tostyle.fill()
etc...Edit: I wonder if a nice move could be...
(In a sense, this means that
polars.selectors.all()
is equivalent to athis
construct)Big questions
matplotlib.cm.coolwarm()
and friends return an array of N_obs x 4 (rgba values). We don't necessarily need to support it, but I'm curious what else is out there!