From 57ea00c026cf2b4c69ba3c514e19e55fefdd54eb Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Wed, 2 Apr 2014 22:36:53 -0400 Subject: [PATCH 1/2] BUG/API : tweaked how AnchoredSizeBar handles font properties - removed the explicit `prop` from `mpl_toolkits.axes_grid1.anchored_artists.AnchoredSizeBar` - pass `fontproperties` through to the base class in place of `prop` - if `prop` is not None and `fontproperties` is None, then use `prop` in place of `fontproperties`. --- doc/api/api_changes.rst | 8 ++++++ .../axes_grid1/anchored_artists.py | 27 ++++++++++++------- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/doc/api/api_changes.rst b/doc/api/api_changes.rst index e795ae9c837f..2c0f690dfccf 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,8 @@ Code removal a long time) and was not the standard form of the Levy distribution. ``scipy.stats.levy`` should be used instead + +>>>>>>> BUG/API : tweaked how AnchoredSizeBar handles font properties .. _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) From 40c4fe71796e4c6182a1d49aead3aebe8ff999f5 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Thu, 26 Jun 2014 21:05:01 -0400 Subject: [PATCH 2/2] cleaned up rouge merge lines --- doc/api/api_changes.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/api/api_changes.rst b/doc/api/api_changes.rst index 2c0f690dfccf..5278be771bc9 100644 --- a/doc/api/api_changes.rst +++ b/doc/api/api_changes.rst @@ -186,7 +186,6 @@ Code removal ``scipy.stats.levy`` should be used instead ->>>>>>> BUG/API : tweaked how AnchoredSizeBar handles font properties .. _changes_in_1_3: