From e42be4dc3e853f9c45b4309adfcd8e770a8eb111 Mon Sep 17 00:00:00 2001 From: Magnus Nord Date: Fri, 30 Jun 2017 14:25:45 +0100 Subject: [PATCH 1/3] ENH: add fill argument to AnchoredSizeBar --- lib/mpl_toolkits/axes_grid1/anchored_artists.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/mpl_toolkits/axes_grid1/anchored_artists.py b/lib/mpl_toolkits/axes_grid1/anchored_artists.py index ac5eaf29039e..9e1fb3003019 100644 --- a/lib/mpl_toolkits/axes_grid1/anchored_artists.py +++ b/lib/mpl_toolkits/axes_grid1/anchored_artists.py @@ -232,7 +232,7 @@ class AnchoredSizeBar(AnchoredOffsetbox): 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, + fill=False, label_top=False, fontproperties=None, **kwargs): """ Draw a horizontal scale bar with a center-aligned label underneath. @@ -288,6 +288,9 @@ def __init__(self, transform, size, label, loc, Color for the size bar and label. Defaults to black. + fill : bool, optional + Sizebar rectangle fill. Defaults to False. + label_top : bool, optional If True, the label will be over the size bar. Defaults to False. @@ -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: From 71c83fe95428ce20efa83186f57b7696a1a65d3e Mon Sep 17 00:00:00 2001 From: Magnus Nord Date: Fri, 30 Jun 2017 17:40:52 +0100 Subject: [PATCH 2/3] AnchoredSizeBar: move fill argument last to not break API --- lib/mpl_toolkits/axes_grid1/anchored_artists.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/mpl_toolkits/axes_grid1/anchored_artists.py b/lib/mpl_toolkits/axes_grid1/anchored_artists.py index 9e1fb3003019..358f12f835e0 100644 --- a/lib/mpl_toolkits/axes_grid1/anchored_artists.py +++ b/lib/mpl_toolkits/axes_grid1/anchored_artists.py @@ -232,8 +232,8 @@ class AnchoredSizeBar(AnchoredOffsetbox): def __init__(self, transform, size, label, loc, pad=0.1, borderpad=0.1, sep=2, frameon=True, size_vertical=0, color='black', - fill=False, label_top=False, fontproperties=None, - **kwargs): + label_top=False, fontproperties=None, + fill=False, **kwargs): """ Draw a horizontal scale bar with a center-aligned label underneath. @@ -288,9 +288,6 @@ def __init__(self, transform, size, label, loc, Color for the size bar and label. Defaults to black. - fill : bool, optional - Sizebar rectangle fill. Defaults to False. - label_top : bool, optional If True, the label will be over the size bar. Defaults to False. @@ -298,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`. From c7b2f3c864db6f09e6d67904eb494a1eed876207 Mon Sep 17 00:00:00 2001 From: Magnus Nord Date: Fri, 30 Jun 2017 17:42:11 +0100 Subject: [PATCH 3/3] AnchoredSizeBar, fill argument: add note in whats_new --- doc/users/whats_new/anchoredsizebar_fill_argument.rst | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 doc/users/whats_new/anchoredsizebar_fill_argument.rst 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.