legend

This module provides the Legend class.

class mATLASplotlib.decorations.legend.Legend

Bases: object

Class for controlling plot legends.

__init__()

Initialise legend ordering and default fontsize.

add_dataset(label, is_stack=False, sort_as=None)

Add a dataset to the legend.

Parameters:
  • label (str) – label that will appear in the legend
  • is_stack (bool) – if this is a stack plot it needs to be stored in reverse order
  • sort_as (str) – override the default first-in-first-out sorting, and sort using this text instead
plot(x, y, axes, anchor_to, fontsize, use_axes=False)

Plot the legend at (x, y) on the chosen axes.

Parameters:
  • x (float) – x-position of legend
  • y (float) – y-position of legend
  • axes (str) – axes to plot on
  • anchor_to (str) – which corner to anchor the (x, y) to
  • fontsize (float) – fontsize of legend contents
  • use_axes (list[matplotlib.axes.Axes]) – get handles and labels from all axes in list