Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ff1d64b

Browse filesBrowse files
committed
Oops in last commit
svn path=/branches/transforms/; revision=4578
1 parent b3dd8c4 commit ff1d64b
Copy full SHA for ff1d64b

File tree

Expand file treeCollapse file tree

1 file changed

+12
-46
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+12
-46
lines changed

‎lib/matplotlib/axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes.py
+12-46Lines changed: 12 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
from matplotlib import lines as mlines
2222
from matplotlib import mlab
2323
from matplotlib import patches as mpatches
24-
from matplotlib import path as mpath
2524
from matplotlib import quiver as mquiver
2625
from matplotlib import scale as mscale
2726
from matplotlib import table as mtable
@@ -771,14 +770,13 @@ def cla(self):
771770

772771
self.grid(self._gridOn)
773772
props = font_manager.FontProperties(size=rcParams['axes.titlesize'])
774-
self.titleOffsetTrans = mtransforms.Affine2D()
775-
self.title = mtext.Text(
776-
x=0.5, y=1.00, text='',
773+
self.title = mtext.Text(
774+
x=0.5, y=1.02, text='',
777775
fontproperties=props,
778776
verticalalignment='bottom',
779777
horizontalalignment='center',
780778
)
781-
self.title.set_transform(self.transAxes + self.titleOffsetTrans)
779+
self.title.set_transform(self.transAxes)
782780
self.title.set_clip_box(None)
783781

784782
self._set_artist_props(self.title)
@@ -802,8 +800,6 @@ def cla(self):
802800
self.xaxis.set_clip_path(self.axesPatch)
803801
self.yaxis.set_clip_path(self.axesPatch)
804802

805-
self.titleOffsetTrans.clear()
806-
807803
def clear(self):
808804
'clear the axes'
809805
self.cla()
@@ -909,14 +905,14 @@ def get_data_ratio(self):
909905
ysize = max(math.fabs(ymax-ymin), 1e-30)
910906
return ysize/xsize
911907

912-
def apply_aspect(self, currentPosition):
908+
def apply_aspect(self):
913909
'''
914910
Use self._aspect and self._adjustable to modify the
915911
axes box or the view limits.
916912
'''
917913
aspect = self.get_aspect()
918914
if aspect == 'auto':
919-
self.set_position(currentPosition, 'active')
915+
self.set_position( self._originalPosition , 'active')
920916
return
921917

922918
if aspect == 'equal':
@@ -933,7 +929,7 @@ def apply_aspect(self, currentPosition):
933929
fig_aspect = figH/figW
934930
if self._adjustable == 'box':
935931
box_aspect = A * self.get_data_ratio()
936-
pb = currentPosition.frozen()
932+
pb = self._originalPosition.frozen()
937933
pb1 = pb.shrunk_to_aspect(box_aspect, pb, fig_aspect)
938934
self.set_position(pb1.anchored(self.get_anchor(), pb), 'active')
939935
return
@@ -1141,7 +1137,7 @@ def add_collection(self, collection, autolim=True):
11411137
self._set_artist_props(collection)
11421138
collection.set_clip_path(self.axesPatch)
11431139
if autolim:
1144-
if len(collection._paths):
1140+
if collection._paths and len(collection._paths):
11451141
self.update_datalim(collection.get_datalim(self.transData))
11461142
collection._remove_method = lambda h: self.collections.remove(h)
11471143

@@ -1293,48 +1289,25 @@ def autoscale_view(self, tight=False, scalex=True, scaley=True):
12931289
YL = ylocator.autoscale()
12941290
self.set_ybound(YL)
12951291

1296-
def adjust_for_axis_text(self, renderer):
1297-
pad_pixels = rcParams['xtick.major.pad'] * self.figure.dpi / 72.0
1298-
inverse_transFigure = self.figure.transFigure.inverted()
1299-
t_text, b_text = self.xaxis.get_text_heights(renderer)
1300-
l_text, r_text = self.yaxis.get_text_widths(renderer)
1301-
title_height = self.title.get_window_extent(renderer).height
1302-
title_height += pad_pixels * 2.0
1303-
original_t_text = t_text
1304-
1305-
((l_text, t_text),
1306-
(r_text, b_text),
1307-
(dummy, title_height)) = inverse_transFigure.transform(
1308-
((l_text, t_text),
1309-
(r_text, b_text),
1310-
(0.0, title_height)))
1311-
x0, y0, x1, y1 = self.get_position(True).extents
1312-
# Adjust the title
1313-
self.titleOffsetTrans.clear().translate(
1314-
0, original_t_text + pad_pixels * 2.0)
1315-
return mtransforms.Bbox.from_extents(
1316-
x0 + l_text, y0 + b_text, x1 - r_text,
1317-
y1 - t_text - title_height)
1318-
13191292
#### Drawing
13201293
def draw(self, renderer=None, inframe=False):
13211294
"Draw everything (plot lines, axes, labels)"
1322-
if renderer is None:
1295+
if renderer is None:
13231296
renderer = self._cachedRenderer
13241297

13251298
if renderer is None:
13261299
raise RuntimeError('No renderer defined')
13271300
if not self.get_visible(): return
13281301
renderer.open_group('axes')
1329-
1330-
currentPosition = self.adjust_for_axis_text(renderer)
1331-
self.apply_aspect(currentPosition)
1302+
self.apply_aspect()
13321303

13331304
if self.axison and self._frameon:
13341305
self.axesPatch.draw(renderer)
13351306

13361307
artists = []
13371308

1309+
1310+
13381311
if len(self.images)<=1 or renderer.option_image_nocomposite():
13391312
for im in self.images:
13401313
im.draw(renderer)
@@ -1346,6 +1319,7 @@ def draw(self, renderer=None, inframe=False):
13461319
ims = [(im.make_image(mag),0,0)
13471320
for im in self.images if im.get_visible()]
13481321

1322+
13491323
im = mimage.from_images(self.bbox.height*mag,
13501324
self.bbox.width*mag,
13511325
ims)
@@ -1386,14 +1360,6 @@ def draw(self, renderer=None, inframe=False):
13861360
a.draw(renderer)
13871361

13881362
renderer.close_group('axes')
1389-
1390-
# ### DEBUGGING
1391-
# gc = renderer.new_gc()
1392-
# gc.set_linewidth(2.0)
1393-
# x0, y0, x1, y1 = self.get_position(True).extents
1394-
# renderer.draw_path(gc, mpath.Path(
1395-
# [[x0, y0], [x0, y1], [x1, y1], [x1, y0], [x0, y0]]),
1396-
# self.figure.transFigure)
13971363
self._cachedRenderer = renderer
13981364

13991365
def draw_artist(self, a):

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.