diff --git a/doc/api/api_changes.rst b/doc/api/api_changes.rst index e795ae9c837f..5278be771bc9 100644 --- a/doc/api/api_changes.rst +++ b/doc/api/api_changes.rst @@ -171,6 +171,12 @@ original location: treated as numpy fancy indexing and only the two markers corresponding to the given indexes will be shown. +* removed prop kwarg from `mpl_toolkits.axes_grid1.anchored_artists.AnchoredSizeBar` + call. It was passed through to the base-class `__init__` and is only used for + setting padding. Now `fontproperties` (which is what is really used to set + the font properties of `AnchoredSizeBar`) is passed through in place of `prop`. + If `fontpropreties` is not passed in, but `prop` is, then `prop` is used inplace + of `fontpropreties`. If both are passed in, `prop` is silently ignored. Code removal ------------ @@ -179,6 +185,7 @@ Code removal a long time) and was not the standard form of the Levy distribution. ``scipy.stats.levy`` should be used instead + .. _changes_in_1_3: diff --git a/lib/mpl_toolkits/axes_grid1/anchored_artists.py b/lib/mpl_toolkits/axes_grid1/anchored_artists.py index fc56ec00d831..1fa0effc4f74 100644 --- a/lib/mpl_toolkits/axes_grid1/anchored_artists.py +++ b/lib/mpl_toolkits/axes_grid1/anchored_artists.py @@ -66,10 +66,9 @@ def __init__(self, transform, width, height, angle, loc, frameon=frameon, **kwargs) - class AnchoredSizeBar(AnchoredOffsetbox): def __init__(self, transform, size, label, loc, - pad=0.1, borderpad=0.1, sep=2, prop=None, + pad=0.1, borderpad=0.1, sep=2, frameon=True, size_vertical=0, color='black', label_top=False, fontproperties=None, **kwargs): @@ -117,24 +116,32 @@ def __init__(self, transform, size, label, loc, >>> fig.show() Using all the optional parameters - + >>> import matplotlib.font_manager as fm >>> fontprops = fm.FontProperties(size=14, family='monospace') - >>> bar = AnchoredSizeBar(ax.transData, 3, '3 units', 4, pad=0.5, sep=5, borderpad=0.5, frameon=False, size_vertical=0.5, color='white', fontproperties=fontprops) + >>> bar = AnchoredSizeBar(ax.transData, 3, '3 units', 4, pad=0.5, sep=5, borderpad=0.5, frameon=False, size_vertical=0.5, color='white', fontproperties=fontprops) # noqa """ self.size_bar = AuxTransformBox(transform) - self.size_bar.add_artist(Rectangle((0,0), size, size_vertical, fill=True, facecolor=color, edgecolor=color)) + self.size_bar.add_artist(Rectangle((0, 0), size, size_vertical, + fill=True, facecolor=color, + edgecolor=color)) - if not fontproperties: + # if fontproperties is None, but `prop` is not, assume that + # prop should be used to set the font properties. This is + # questionable behavior + if fontproperties is None and 'prop' in kwargs: + fontproperties = kwargs.pop('prop') + + if fontproperties is None: textprops = {'color': color} else: - textprops = {'color': color, 'fontproperties': fontproperties} + textprops = {'color': color, 'fontproperties': fontproperties} self.txt_label = TextArea( - label, - minimumdescent=False, + label, + minimumdescent=False, textprops=textprops) if label_top: @@ -148,7 +155,7 @@ def __init__(self, transform, size, label, loc, AnchoredOffsetbox.__init__(self, loc, pad=pad, borderpad=borderpad, child=self._box, - prop=prop, + prop=fontproperties, frameon=frameon, **kwargs)