Use scale_color_cmapmpl()
, scale_fill_cmapmpl()
, or scale_cmapmpl()
to extract colors from a colormap and apply them to your chart.
If a colormap is registered with Matplotlib, you can access it by its name. Otherwise, you can pass a cmap object directly.
Note: These functions require Matplotlib to be installed in your environment.
import numpy as np
from lets_plot import *
LetsPlot.setup_html()
np.random.seed(42)
n = 100
x = np.random.uniform(-1, 1, size=n)
y = 25 * x ** 2 + np.random.normal(size=n)
p = ggplot({'x': x, 'y': y}) \
+ geom_point(aes(x='x', y='y', fill='y'), shape=21, size=7, color='white')
p + scale_fill_cmapmpl('magma')
p + scale_fill_cmapmpl('Dark2')