Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 905bfd7

Browse files
committed
Fix bugs: #2830483 (axis scaling), 2834105 (z order problem)
svn path=/branches/v0_99_maint/; revision=7446
1 parent 5c132e2 commit 905bfd7

3 files changed

Lines changed: 22 additions & 14 deletions

File tree

lib/mpl_toolkits/mplot3d/art3d.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,19 @@ def do_3d_projection(self, renderer):
217217
def draw(self, renderer):
218218
Patch.draw(self, renderer)
219219

220+
def get_patch_verts(patch):
221+
"""Return a list of vertices for the path of a patch."""
222+
trans = patch.get_patch_transform()
223+
path = patch.get_path()
224+
polygons = path.to_polygons(trans)
225+
if len(polygons):
226+
return polygons[0]
227+
else:
228+
return []
229+
220230
def patch_2d_to_3d(patch, z=0, zdir='z'):
221231
"""Convert a Patch to a Patch3D object."""
222-
verts = patch.get_verts()
232+
verts = get_patch_verts(patch)
223233
patch.__class__ = Patch3D
224234
patch.set_3d_properties(verts, z, zdir)
225235

@@ -333,7 +343,7 @@ def do_3d_projection(self, renderer):
333343
if self._zsort:
334344
z_segments_2d = [(np.average(zs), zip(xs, ys), fc, ec) for
335345
(xs, ys, zs), fc, ec in zip(xyzlist, cface, cedge)]
336-
z_segments_2d.sort(reverse=True)
346+
z_segments_2d.sort(cmp=lambda x, y: cmp(y[0], x[0]))
337347
else:
338348
raise ValueError, "whoops"
339349

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -200,14 +200,17 @@ def autoscale_view(self, scalex=True, scaley=True, scalez=True):
200200

201201
def get_w_lims(self):
202202
'''Get 3d world limits.'''
203-
minpy, maxx = self.get_xlim3d()
203+
minx, maxx = self.get_xlim3d()
204204
miny, maxy = self.get_ylim3d()
205205
minz, maxz = self.get_zlim3d()
206-
return minpy, maxx, miny, maxy, minz, maxz
206+
return minx, maxx, miny, maxy, minz, maxz
207207

208208
def _determine_lims(self, xmin=None, xmax=None, *args, **kwargs):
209209
if xmax is None and cbook.iterable(xmin):
210210
xmin, xmax = xmin
211+
if xmin == xmax:
212+
xmin -= 0.5
213+
xmax += 0.5
211214
return (xmin, xmax)
212215

213216
def set_xlim3d(self, *args, **kwargs):
@@ -442,12 +445,12 @@ def _on_move(self, event):
442445
elif self.button_pressed == 3:
443446
# zoom view
444447
# hmmm..this needs some help from clipping....
445-
minpy, maxx, miny, maxy, minz, maxz = self.get_w_lims()
448+
minx, maxx, miny, maxy, minz, maxz = self.get_w_lims()
446449
df = 1-((h - dy)/h)
447-
dx = (maxx-minpy)*df
450+
dx = (maxx-minx)*df
448451
dy = (maxy-miny)*df
449452
dz = (maxz-minz)*df
450-
self.set_xlim3d(minpy - dx, maxx + dx)
453+
self.set_xlim3d(minx - dx, maxx + dx)
451454
self.set_ylim3d(miny - dy, maxy + dy)
452455
self.set_zlim3d(minz - dz, maxz + dz)
453456
self.get_proj()
@@ -903,13 +906,12 @@ def bar(self, left, height, zs=0, zdir='z', *args, **kwargs):
903906
patches = Axes.bar(self, left, height, *args, **kwargs)
904907

905908
if not cbook.iterable(zs):
906-
zs = np.ones(len(left))*zs
907-
909+
zs = np.ones(len(left)) * zs
908910

909911
verts = []
910912
verts_zs = []
911913
for p, z in zip(patches, zs):
912-
vs = p.get_verts()
914+
vs = art3d.get_patch_verts(p)
913915
verts += vs.tolist()
914916
verts_zs += [z] * len(vs)
915917
art3d.patch_2d_to_3d(p, zs, zdir)
@@ -933,7 +935,6 @@ def bar3d(self, x, y, z, dx, dy, dz, color='b'):
933935
had_data = self.has_data()
934936

935937
if not cbook.iterable(x):
936-
print 'not interable'
937938
x, y, z = [x], [y], [z]
938939
if not cbook.iterable(dx):
939940
dx, dy, dz = [dx], [dy], [dz]

lib/mpl_toolkits/mplot3d/axis3d.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,6 @@ def get_tick_positions(self):
103103
def get_major_ticks(self):
104104
ticks = maxis.XAxis.get_major_ticks(self)
105105
for t in ticks:
106-
def update_coords(renderer, self=t.label1):
107-
return text_update_coords(self, renderer)
108-
# Text overrides setattr so need this to force new method
109106
t.tick1line.set_transform(self.axes.transData)
110107
t.tick2line.set_transform(self.axes.transData)
111108
t.gridline.set_transform(self.axes.transData)

0 commit comments

Comments
 (0)