seaborn.objects.Plot.label#
- Plot.label(*, title=None, **variables)#
Control the labels and titles for axes, legends, and subplots.
Additional keywords correspond to variables defined in the plot. Values can be one of the following types:
string (used literally; pass “” to clear the default label)
function (called on the default label)
For coordinate variables, the value sets the axis label. For semantic variables, the value sets the legend title. For faceting variables,
title=
modifies the subplot-specific label, whilecol=
and/orrow=
add a label for the faceting variable. When using a single subplot,title=
sets its title.Examples
Use strings to override default labels:
p = ( so.Plot(penguins, x="bill_length_mm", y="bill_depth_mm") .add(so.Dot(), color="species") ) p.label(x="Length", y="Depth", color="")
Pass a function to modify the default label:
p.label(color=str.capitalize)
Use this method to set the title for a single-axes plot:
p.label(title="Penguin species exhibit distinct bill shapes")
When faceting, the
title
parameter will modify default titles:p.facet("sex").label(title=str.upper)
And the
col
/row
parameters will add labels to the title for each facet:p.facet("sex").label(col="Sex:")
If more customization is needed, a format string can work well:
p.facet("sex").label(title="{} penguins".format)