8000 Cleanup axes_grid1.anchored_artists · matplotlib/matplotlib@efb3f5a · GitHub
[go: up one dir, main page]

Skip to content

Commit efb3f5a

Browse files
committed
Cleanup axes_grid1.anchored_artists
Remove non-library (and unusable) code Remove unused imports Fixed pylint issues with indentation
1 parent 4573e1e commit efb3f5a

File tree

1 file changed

+7
-87
lines changed

1 file changed

+7
-87
lines changed

lib/mpl_toolkits/axes_grid1/anchored_artists.py

Lines changed: 7 additions & 87 deletions
10000
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
from __future__ import (absolute_import, division, print_function,
22
unicode_literals)
33

4-
from matplotlib.externals import six
5-
4+
from matplotlib.offsetbox import (AnchoredOffsetbox, AuxTransformBox,
5+
DrawingArea, TextArea, VPacker)
66
from matplotlib.patches import Rectangle, Ellipse
77

8-
import numpy as np
9-
10-
from matplotlib.offsetbox import AnchoredOffsetbox, AuxTransformBox, VPacker,\
11-
TextArea, AnchoredText, DrawingArea, AnnotationBbox
12-
138

149
class AnchoredDrawingArea(AnchoredOffsetbox):
1510
"""
@@ -23,21 +18,18 @@ def __init__(self, width, height, xdescent, ydescent,
2318
*width*, *height*, *xdescent*, *ydescent* : the dimensions of the DrawingArea.
2419
*prop* : font property. This is only used for scaling the paddings.
2520
"""
26-
2721
self.da = DrawingArea(width, height, xdescent, ydescent)
2822
self.drawing_area = self.da
2923

30-
super(AnchoredDrawingArea, self).__init__(loc, pad=pad, borderpad=borderpad,
31-
child=self.da,
32-
prop=None,
33-
frameon=frameon,
34-
**kwargs)
24+
super(AnchoredDrawingArea, self).__init__(
25+
loc, pad=pad, borderpad=borderpad, child=self.da, prop=None,
26+
frameon=frameon, **kwargs
27+
)
3528

3629

3730
class AnchoredAuxTransformBox(AnchoredOffsetbox):
3831
def __init__(self, transform, loc,
3932
pad=0.4, borderpad=0.5, prop=None, frameon=True, **kwargs):
40-
4133
self.drawing_area = AuxTransformBox(transform)
4234

4335
AnchoredOffsetbox.__init__(self, loc, pad=pad, borderpad=borderpad,
@@ -47,7 +39,6 @@ def __init__(self, transform, loc,
4739
**kwargs)
4840

4941

50-
5142
class AnchoredEllipse(AnchoredOffsetbox):
5243
def __init__(self, transform, width, height, angle, loc,
5344
pad=0.1, borderpad=0.1, prop=None, frameon=True, **kwargs):
@@ -57,7 +48,7 @@ def __init__(self, transform, width, height, angle, loc,
5748
pad, borderpad in fraction of the legend font size (or prop)
5849
"""
5950
self._box = AuxTransformBox(transform)
60-
self.ellipse = Ellipse((0,0), width, height, angle)
51+
self.ellipse = Ellipse((0, 0), width, height, angle)
6152
self._box.add_artist(self.ellipse)
6253

6354
AnchoredOffsetbox.__init__(self, loc, pad=pad, borderpad=borderpad,
@@ -122,7 +113,6 @@ def __init__(self, transform, size, label, loc,
122113
>>> 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)
123114
124115
"""
125-
126116
self.size_bar = AuxTransformBox(transform)
127117
self.size_bar.add_artist(Rectangle((0, 0), size, size_vertical,
128118
fill=True, facecolor=color,
@@ -157,73 +147,3 @@ def __init__(self, transform, size, label, loc,
157147
child=self._box,
158148
prop=fontproperties,
159149
frameon=frameon, **kwargs)
160-
161-
162-
if __name__ == "__main__":
163-
164-
import matplotlib.pyplot as plt
165-
166-
fig = plt.gcf()
167-
fig.clf()
168-
ax = plt.subplot(111)
169-
170-
offsetbox = AnchoredText("Test", loc=6, pad=0.3,
171-
borderpad=0.3, prop=None)
172-
xy = (0.5, 0.5)
173-
ax.plot([0.5], [0.5], "xk")
174-
ab = AnnotationBbox(offsetbox, xy,
175-
xybox=(1., .5),
176-
xycoords='data',
177-
boxcoords=("axes fraction", "data"),
178-
arrowprops=dict(arrowstyle="->"))
179-
#arrowprops=None)
180-
181-
ax.add_artist(ab)
182-
183-
184-
from matplotlib.patches import Circle
185-
ada = AnchoredDrawingArea(20, 20, 0, 0,
186-
loc=6, pad=0.1, borderpad=0.3, frameon=True)
187-
p = Circle((10, 10), 10)
188-
ada.da.add_artist(p)
189-
190-
ab = AnnotationBbox(ada, (0.3, 0.4),
191-
xybox=(1., 0.4),
192-
xycoords='data',
193-
boxcoords=("axes fraction", "data"),
194-
arrowprops=dict(arrowstyle="->"))
195-
#arrowprops=None)
196-
197-
ax.add_artist(ab)
198-
199-
200-
arr = np.arange(100).reshape((10,10))
201-
im = AnchoredImage(arr,
202-
loc=4,
203-
pad=0.5, borderpad=0.2, prop=None, frameon=True,
204-
zoom=1,
205-
cmap = None,
206-
norm = None,
207-
interpolation=None,
208-
origin=None,
209-
extent=None,
210-
filternorm=1,
211-
filterrad=4.0,
212-
resample = False,
213-
)
214-
215-
ab = AnnotationBbox(im, (0.5, 0.5),
216-
xybox=(-10., 10.),
217-
xycoords='data',
218-
boxcoords="offset points",
219-
arrowprops=dict(arrowstyle="->"))
220-
#arrowprops=None)
221-
222-
ax.add_artist(ab)
223-
224-
ax.set_xlim(0, 1)
225-
ax.set_ylim(0, 1)
226-
227-
228-
plt.draw()
229-
plt.show()

0 commit comments

Comments
 (0)
0