override_aes
¶The override_aes
parameter in guide_legend()
allows you to change the legend appearance.
import pandas as pd
from lets_plot import *
LetsPlot.setup_html()
mpg = pd.read_csv ("https://raw.githubusercontent.com/JetBrains/lets-plot-docs/master/data/mpg.csv")
mpg.head(3)
Unnamed: 0 | manufacturer | model | displ | year | cyl | trans | drv | cty | hwy | fl | class | |
---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1 | audi | a4 | 1.8 | 1999 | 4 | auto(l5) | f | 18 | 29 | p | compact |
1 | 2 | audi | a4 | 1.8 | 1999 | 4 | manual(m5) | f | 21 | 29 | p | compact |
2 | 3 | audi | a4 | 2.0 | 2008 | 4 | manual(m6) | f | 20 | 31 | p | compact |
# Default legend
p = ggplot(mpg, aes('displ', 'hwy', color='drv')) + \
geom_point(size=4, alpha=0.2, stroke=0)
p
# override_aes
p + guides(color=guide_legend(override_aes={'alpha': 0.3, 'size': 8}))