Updated custom legend formatting
This PR changes the way legends are customised by default, to make things easier to modify for the user.
The old way was to use some extra keyword arguments, namely linewidth
, to specify a new default linewidth in the legend. However, those keywords aren't recognised by default matplotlib figures, so calling ax.legend(linewidth=4)
isn't cross-compatible between gwpy and non-gwpy plots. There's also no way to disable the custom linewidth and use the linewidth of the original handle.
The new way is to define a custom legend handler, which operates on Line2D
objects, and sets the default linewidth. The interface is now that gwpy's Axes.legend
method inserts the new handler into the existing handler_map
keyword of matplotlib's Axes.legend
method, which is entirely cross-compatible with non-gwpy plots. This gwpy handler can be disabled simply be passing handler_map=None
to `ax.legend().
This PR also includes a docs page that describes the legend customisation, how to disable it, or how to modify it with your own custom legend handler.