breaks and lables arguments in scale_xxx() function family each accepts list of values for customizing the scale breaks or labels.
However, it is often more convenient to use a dictionary of breaks (in the labels parameter) or a dictionary of labels (in the breaks parameter) for the breaks/labels customization.
Similar situation is with parameters breaks and values in the scale_xxx_manual() function family.
import pandas as pd
from lets_plot import *
LetsPlot.setup_html()
mpg_df = pd.read_csv ("https://raw.githubusercontent.com/JetBrains/lets-plot-docs/master/data/mpg.csv")
mpg_df.head(3)
p = ggplot(mpg_df, aes(x='displ', y='hwy', color='drv')) + geom_point()
p
p = p + scale_color_discrete(labels={
'f': 'front',
'r': 'rear',
'4': '4WD'
})
p
breaks and labels¶p = p + scale_x_continuous(breaks={
'min': 1.6,
'3.4': 3.4,
'5.2': 5.2,
'max': 7
})
p
p + scale_color_manual(values={
'f': 'dark_blue',
'r': 'dark_green',
'4': 'dark_magenta'
})