publiplots.set_axis_labels#

publiplots.set_axis_labels(ax, xlabel=None, ylabel=None, title=None, fontsize=None, fontweight=None)[source]#

Set axis labels and title with consistent formatting.

Only labels that are explicitly provided are set; None values leave the existing label / title untouched.

Parameters:
  • ax (matplotlib.axes.Axes) – Axes to modify in place.

  • xlabel (str, optional) – X-axis label. None leaves it unchanged.

  • ylabel (str, optional) – Y-axis label. None leaves it unchanged.

  • title (str, optional) – Plot title. None leaves it unchanged.

  • fontsize (float, optional) – Font size (points) for labels and title. None omits the kwarg entirely, so labels keep axes.labelsize and the title keeps axes.titlesize.

  • fontweight (str, optional) – Font weight — e.g. 'normal', 'bold', 'light'. None omits the kwarg entirely, so labels keep axes.labelweight and the title keeps axes.titleweight.

Notes

Each font kwarg is omitted when not supplied rather than forwarded as None: matplotlib’s set_fontsize(None) / set_fontweight(None) reset the text to the generic font.size / font.weight, which would discard the per-role rcParam already applied at creation.

Examples

>>> pp.set_axis_labels(ax, xlabel='Time (s)', ylabel='Signal',
...                    title='Results')