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 general color maps #263

Closed
MarcSkovMadsen opened this issue Nov 26, 2023 · 1 comment · Fixed by #289
Closed

Support general color maps #263

MarcSkovMadsen opened this issue Nov 26, 2023 · 1 comment · Fixed by #289

Comments

@MarcSkovMadsen
Copy link
Contributor

It seems your apply_continuous_cmap is very tied to palettable.

I experienced this a friction as I'm used to using Colorcet. So I ended up creating some functionality to convert from colorcet to palettable in #262.

I'm not very well versed in colormaps but I would think that tying it to one provider is friction.

@kylebarron
Copy link
Member

I hadn't previously used colormaps in python much, and so I figured the easiest approach was to nudge people towards a library with lots of colormaps.

To be clear, apply_continuous_cmap is only a helper for creating a numpy array that's of shape (n, 3) or (n, 4) and data type uint8 for passing into anything that accepts a color. Part of the primary goal in lonboard is to say "use the full range of python to do whatever you want that outputs a column of colors to render". So for example, I'm not familiar with colorcet but it looks like you can get matplotlib-compatible colormaps easily. So you can do

from matplotlib.cm import get_cmap

data = np.array(...)
colormap = get_cmap("cet_fire")
map_.get_fill_color = colormap(data, bytes=True)

(bytes=True makes it uint8 output 0-255 instead of float 0-1).

That said, it's probably good to update apply_continuous_cmap to support at least either any palettable colormap or any matplotlib colormap object (though for the matplotlib colormap it would literally just be an alias to call colormap(data, bytes=True).

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

Successfully merging a pull request may close this issue.

2 participants