Thanks to visit codestin.com
Credit goes to github.com

Skip to content

ENH: add fill argument to AnchoredSizeBar #8829

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions doc/users/whats_new/anchoredsizebar_fill_argument.rst
Original file line number Diff line number Diff line change
@@ -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.
7 changes: 5 additions & 2 deletions lib/mpl_toolkits/axes_grid1/anchored_artists.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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`.
Expand Down Expand Up @@ -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:
Expand Down