diff --git a/lib/matplotlib/figure.py b/lib/matplotlib/figure.py index 986870c78140..f9dafd71350d 100644 --- a/lib/matplotlib/figure.py +++ b/lib/matplotlib/figure.py @@ -1184,6 +1184,10 @@ def legend(self, handles, labels, *args, **kwargs): *title* : string the legend title + *uniform_size*: [ *None* | scalar ] + a uniform size of legend markers. If *None*, use original plot + settings + Padding and spacing between various elements use following keywords parameters. The dimensions of these values are given as a fraction of the fontsize. Values from rcParams will be used if None. diff --git a/lib/matplotlib/legend.py b/lib/matplotlib/legend.py index c7423fb4518c..898f55207c4a 100644 --- a/lib/matplotlib/legend.py +++ b/lib/matplotlib/legend.py @@ -185,6 +185,7 @@ def __init__(self, parent, handles, labels, bbox_transform=None, # transform for the bbox frameon=None, # draw frame handler_map=None, + uniform_size=None, # set legend points to be a uniform size ): """ - *parent*: the artist that contains the legend @@ -223,6 +224,7 @@ def __init__(self, parent, handles, labels, title the legend title bbox_to_anchor the bbox that the legend will be anchored. bbox_transform the transform for the bbox. transAxes if None. + uniform_size the uniform size of legend marker ================ ==================================================== @@ -245,6 +247,13 @@ def __init__(self, parent, handles, labels, Artist.__init__(self) + if uniform_size is not None: + uniform_handler_map = { + PathCollection: + legend_handler.HandlerPathCollection(sizes=[uniform_size]), + } + self.update_default_handler_map(uniform_handler_map) + if prop is None: if fontsize is not None: self.prop = FontProperties(size=fontsize)