@@ -66,10 +66,9 @@ def __init__(self, transform, width, height, angle, loc,
66
66
frameon = frameon , ** kwargs )
67
67
68
68
69
-
70
69
class AnchoredSizeBar (AnchoredOffsetbox ):
71
70
def __init__ (self , transform , size , label , loc ,
72
- pad = 0.1 , borderpad = 0.1 , sep = 2 , prop = None ,
71
+ pad = 0.1 , borderpad = 0.1 , sep = 2 ,
73
72
frameon = True , size_vertical = 0 , color = 'black' ,
74
73
label_top = False , fontproperties = None ,
75
74
** kwargs ):
@@ -117,24 +116,32 @@ def __init__(self, transform, size, label, loc,
117
116
>>> fig.show()
118
117
119
118
Using all the optional parameters
120
-
119
+
121
120
>>> import matplotlib.font_manager as fm
122
121
>>> fontprops = fm.FontProperties(size=14, family='monospace')
123
- >>> 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)
122
+ >>> 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
124
123
125
124
"""
126
125
127
126
self .size_bar = AuxTransformBox (transform )
128
- self .size_bar .add_artist (Rectangle ((0 ,0 ), size , size_vertical , fill = True , facecolor = color , edgecolor = color ))
127
+ self .size_bar .add_artist (Rectangle ((0 , 0 ), size , size_vertical ,
128
+ fill = True , facecolor = color ,
129
+ edgecolor = color ))
129
130
130
- if not fontproperties :
131
+ # if fontproperties is None, but `prop` is not, assume that
132
+ # prop should be used to set the font properties. This is
133
+ # questionable behavior
134
+ if fontproperties is None and 'prop' in kwargs :
135
+ fontproperties = kwargs .pop ('prop' )
136
+
137
+ if fontproperties is None :
131
138
textprops = {'color' : color }
132
139
else :
133
- textprops = {'color' : color , 'fontproperties' : fontproperties }
140
+ textprops = {'color' : color , 'fontproperties' : fontproperties }
134
141
135
142
self .txt_label = TextArea (
136
- label ,
137
- minimumdescent = False ,
143
+ label ,
144
+ minimumdescent = False ,
138
145
textprops = textprops )
139
146
140
147
if label_top :
@@ -148,7 +155,7 @@ def __init__(self, transform, size, label, loc,
148
155
149
156
AnchoredOffsetbox .__init__ (self , loc , pad = pad , borderpad = borderpad ,
150
157
child = self ._box ,
151
- prop = prop ,
158
+ prop = fontproperties ,
152
159
frameon = frameon , ** kwargs )
153
160
154
161
0 commit comments