Axes.legend

Axes.legend(*args, loc=None, width=None, space=None, **kwargs)[source]

Add an inset legend or outer legend along the edge of the axes. See legend_wrapper for details.

Parameters
  • loc (int or str, optional) – The legend location or panel location. The following location keys are valid. Note that if a panel does not exist, it will be generated on-the-fly.

    Location

    Valid keys

    left panel

    'left', 'l'

    right panel

    'right', 'r'

    bottom panel

    'bottom', 'b'

    top panel

    'top', 't'

    “best” inset

    'best', 'inset', 'i', 0

    upper right inset

    'upper right', 'ur', 1

    upper left inset

    'upper left', 'ul', 2

    lower left inset

    'lower left', 'll', 3

    lower right inset

    'lower right', 'lr', 4

    center left inset

    'center left', 'cl', 5

    center right inset

    'center right', 'cr', 6

    lower center inset

    'lower center', 'lc', 7

    upper center inset

    'upper center', 'uc', 8

    center inset

    'center', 'c', 9

  • width (float or str, optional) – For outer legends only. The space allocated for the legend box. This does nothing if rc.tight is True. Units are interpreted by units.

  • space (float or str, optional) – For outer legends only. The space between the axes and the legend box. Units are interpreted by units. When rc.tight is True, this is adjusted automatically. Otherwise, the default is rc[‘subplots.panelpad’] = '0.5em'.

Other Parameters

*args, **kwargs – Passed to legend_wrapper.