You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While the color scale functions in lets-plot are awesome, I would like to propose adding a function that can read any colormap given in the Matplotlib format. This would be different from ..._color_brewer() and ..._color_viridis() as it would take the name of the colormap imported from another package as an argument.
Several packages exist for scientific colormaps (cmcrameri, CMOcean, etc., see this article) and most of them are designed so colormaps can be directly used with Matplotlib.
In order to use such colormaps with lets-plot, I wrote a small function (ggcmap2hex()) that translates colormaps (in Matplotlib format) into a list of hex codes. The list can then be used in the scale_xxxx_gradientn() function in lets-plot (xxxx being either fill or color).
Currently, this function relies on Matplotlib, which makes it dependent on Matplotlib and on its versions. Which is not what you want but I couldn't code it natively for lets-plot :$
It would be super cool if you guys could implement such a function to be used in scale_xxxx_gradientn(). Or to create a new function called something like scale_xxxx_colormap() or scale_xxxx_cmap() that would do scale_xxxx_gradientn(colors=ggcmap2hex(cm.jet)) such as :
from matplotlib import cm
...
...
+ scale_color_cmap(cm.turbo)
or
import cmcrameri.cm as cmc
...
...
+ scale_fill_cmap(cmc.batlow)
I attached a notebook that contains ggcmap2hex() and a demo. ggcmap2hex.zip
The text was updated successfully, but these errors were encountered:
Hi guys,
While the color scale functions in lets-plot are awesome, I would like to propose adding a function that can read any colormap given in the Matplotlib format. This would be different from
..._color_brewer()
and ..._color_viridis()
as it would take the name of the colormap imported from another package as an argument.Several packages exist for scientific colormaps (cmcrameri, CMOcean, etc., see this article) and most of them are designed so colormaps can be directly used with Matplotlib.
In order to use such colormaps with lets-plot, I wrote a small function (
ggcmap2hex()
) that translates colormaps (in Matplotlib format) into a list of hex codes. The list can then be used in thescale_xxxx_gradientn()
function in lets-plot (xxxx being either fill or color).Currently, this function relies on Matplotlib, which makes it dependent on Matplotlib and on its versions. Which is not what you want but I couldn't code it natively for lets-plot :$
It would be super cool if you guys could implement such a function to be used in
scale_xxxx_gradientn()
. Or to create a new function called something likescale_xxxx_colormap()
orscale_xxxx_cmap()
that would doscale_xxxx_gradientn(colors=ggcmap2hex(cm.jet))
such as :or
I attached a notebook that contains
ggcmap2hex()
and a demo.ggcmap2hex.zip
The text was updated successfully, but these errors were encountered: