Scale
Functions with Parameter aesthetic
¶scale_identity(aesthetic, *, ...)
scale_manual(aesthetic, values, *, ...)
scale_continuous(aesthetic, *, ...)
scale_gradient(aesthetic, *, ...)
scale_gradient2(aesthetic, *, ...)
scale_gradientn(aesthetic, *, ...)
scale_hue(aesthetic, *, ...)
scale_discrete(aesthetic, *, ...)
scale_grey(aesthetic, *, ...)
scale_brewer(aesthetic, *, ...)
scale_viridis(aesthetic, *, ...)
Comparing to familiar "scale" functions like scale_color_gradient()
etc., the new set of functions
adds more flexibility by allowing specifying an aesthetic or a list of aesthetics the scale is working with.
For example, you can use just one function call to setup the same color palette for both, stroke and fill colors on plot:
scale_brewer(['color', 'fill'], palette='Set1')
But, the main reason why you might want to use new "scale" functions is configuring of additional color aesthetics: paint_a, paint_b, paint_c
.
These aesthetics are flexible and can be used as either "color" or "fill" as needed. See Multiple Color Scales.
import pandas as pd
from lets_plot import *
from lets_plot.mapping import as_discrete
LetsPlot.setup_html()
mpg_df = pd.read_csv("https://raw.githubusercontent.com/JetBrains/lets-plot-docs/master/data/mpg.csv")
p = ggplot(mpg_df, aes(as_discrete('drv', order=-1), 'hwy')) + \
geom_violin(aes(color='drv', fill='drv'), alpha=.5, size=2)
p
p + scale_color_brewer(palette='Set1') + scale_fill_brewer(palette='Set1')
p + scale_brewer(['color', 'fill'], palette='Set1')