diff --git a/doc/users/whats_new/anchoredsizebar_fill_argument.rst b/doc/users/whats_new/anchoredsizebar_fill_argument.rst new file mode 100644 index 000000000000..d30a85ec121f --- /dev/null +++ b/doc/users/whats_new/anchoredsizebar_fill_argument.rst @@ -0,0 +1,6 @@ +Add fill argument to `AnchoredSizeBar` +-------------------------------------- + +The mpl_toolkits class :class:`~mpl_toolkits.axes_grid1.anchored_artists.AnchoredSizeBar` +now has an additional ``fill`` argument, which makes the rectangle solid instead of just +drawing the border of the rectangle. The default is False. diff --git a/lib/mpl_toolkits/axes_grid1/anchored_artists.py b/lib/mpl_toolkits/axes_grid1/anchored_artists.py index ac5eaf29039e..358f12f835e0 100644 --- a/lib/mpl_toolkits/axes_grid1/anchored_artists.py +++ b/lib/mpl_toolkits/axes_grid1/anchored_artists.py @@ -233,7 +233,7 @@ def __init__(self, transform, size, label, loc, pad=0.1, borderpad=0.1, sep=2, frameon=True, size_vertical=0, color='black', label_top=False, fontproperties=None, - **kwargs): + fill=False, **kwargs): """ Draw a horizontal scale bar with a center-aligned label underneath. @@ -295,6 +295,9 @@ def __init__(self, transform, size, label, loc, fontproperties : `matplotlib.font_manager.FontProperties`, optional Font properties for the label text. + fill : bool, optional + Sizebar rectangle fill. Defaults to False. + **kwargs : Keyworded arguments to pass to :class:`matplotlib.offsetbox.AnchoredOffsetbox`. @@ -336,7 +339,7 @@ def __init__(self, transform, size, label, loc, """ self.size_bar = AuxTransformBox(transform) self.size_bar.add_artist(Rectangle((0, 0), size, size_vertical, - fill=False, facecolor=color, + fill=fill, facecolor=color, edgecolor=color)) if fontproperties is None and 'prop' in kwargs: