10000 Implement tacaswell's suggestions · matplotlib/matplotlib@48519ed · GitHub
[go: up one dir, main page]

Skip to content

Commit 48519ed

Browse files
author
Nathan Goldbaum
committed
Implement tacaswell's suggestions
1 parent 3f2567e commit 48519ed

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Add fill_bar argument to ``AnchoredSizeBar``
2+
--------------------------------------------
3+
4+
The mpl_toolkits class
5+
:class:`~mpl_toolkits.axes_grid1.anchored_artists.AnchoredSizeBar` now has an
6+
additional ``fill_bar`` argument, which makes the size bar a solid rectangle
7+
instead of just drawing the border of the rectangle. The default is ``None``,
8+
and whether or not the bar will be filled by default depends on the value of
9+
``size_vertical``. If ``size_vertical`` is nonzero, ``fill_bar`` will be set to
10+
``True``. If ``size_vertical`` is zero then ``fill_bar`` will be set to
11+
``False``. If you wish to override this default behavior, set ``fill_bar`` to
12+
``True`` or ``False`` to unconditionally always or never use a filled patch
13+
rectangle for the size bar.

lib/mpl_toolkits/axes_grid1/anchored_artists.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ class AnchoredSizeBar(AnchoredOffsetbox):
232232
def __init__(self, transform, size, label, loc,
233233
pad=0.1, borderpad=0.1, sep=2,
234234
frameon=True, size_vertical=0, color='black',
235-
label_top=False, fontproperties=None, fill_bar=False,
235+
label_top=False, fontproperties=None, fill_bar=None,
236236
**kwargs):
237237
"""
238238
Draw a horizontal scale bar with a center-aligned label underneath.
@@ -298,7 +298,8 @@ def __init__(self, transform, size, label, loc,
298298
fill_bar : bool, optional
299299
If True and if size_vertical is nonzero, the size bar will
300300
be filled in with the color specified by the size bar.
301-
Defaults to False.
301+
Defaults to True if `size_vertical` is greater than
302+
zero and False otherwise.
302303
303304
**kwargs :
304305
Keyworded arguments to pass to
@@ -339,6 +340,9 @@ def __init__(self, transform, size, label, loc,
339340
size_vertical=0.5, color='white', \
340341
fontproperties=fontprops)
341342
"""
343+
if fill_bar is None:
344+
fill_bar = size_vertical > 0
345+
342346
self.size_bar = AuxTransformBox(transform)
343347
self.size_bar.add_artist(Rectangle((0, 0), size, size_vertical,
344348
fill=fill_bar, facecolor=color,

0 commit comments

Comments
 (0)
0