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 3e47c19

Browse filesBrowse files
committed
Don't read 3D properties off the renderer for drawing.
All `Artist`s have a `.axes` attribute from which they can grab any of these things directly.
1 parent ab36eaa commit 3e47c19
Copy full SHA for 3e47c19

File tree

Expand file treeCollapse file tree

2 files changed

+22
-20
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+22
-20
lines changed

‎lib/mpl_toolkits/mplot3d/art3d.py

Copy file name to clipboardExpand all lines: lib/mpl_toolkits/mplot3d/art3d.py
+14-12Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,7 @@ def set_3d_properties(self, z=0, zdir='z'):
135135
def draw(self, renderer):
136136
position3d = np.array((self._x, self._y, self._z))
137137
proj = proj3d.proj_trans_points(
138-
[position3d, position3d + self._dir_vec],
139-
renderer.M)
138+
[position3d, position3d + self._dir_vec], self.axes.M)
140139
dx = proj[0][1] - proj[0][0]
141140
dy = proj[1][1] - proj[1][0]
142141
angle = math.degrees(math.atan2(dy, dx))
@@ -213,7 +212,7 @@ def get_data_3d(self):
213212
@artist.allow_rasterization
214213
def draw(self, renderer):
215214
xs3d, ys3d, zs3d = self._verts3d
216-
xs, ys, zs = proj3d.proj_transform(xs3d, ys3d, zs3d, renderer.M)
215+
xs, ys, zs = proj3d.proj_transform(xs3d, ys3d, zs3d, self.axes.M)
217216
self.set_data(xs, ys)
218217
super().draw(renderer)
219218
self.stale = False
@@ -301,9 +300,8 @@ def do_3d_projection(self, renderer):
301300
"""
302301
Project the points according to renderer matrix.
303302
"""
304-
xyslist = [
305-
proj3d.proj_trans_points(points, renderer.M) for points in
306-
self._segments3d]
303+
xyslist = [proj3d.proj_trans_points(points, self.axes.M)
304+
for points in self._segments3d]
307305
segments_2d = [np.column_stack([xs, ys]) for xs, ys, zs in xyslist]
308306
LineCollection.set_segments(self, segments_2d)
309307

@@ -351,7 +349,8 @@ def get_facecolor(self):
351349
def do_3d_projection(self, renderer):
352350
s = self._segment3d
353351
xs, ys, zs = zip(*s)
354-
vxs, vys, vzs, vis = proj3d.proj_transform_clip(xs, ys, zs, renderer.M)
352+
vxs, vys, vzs, vis = proj3d.proj_transform_clip(xs, ys, zs,
353+
self.axes.M)
355354
self._path2d = mpath.Path(np.column_stack([vxs, vys]))
356355
# FIXME: coloring
357356
self._facecolor2d = self._facecolor3d
@@ -375,7 +374,8 @@ def set_3d_properties(self, path, zs=0, zdir='z'):
375374
def do_3d_projection(self, renderer):
376375
s = self._segment3d
377376
xs, ys, zs = zip(*s)
378-
vxs, vys, vzs, vis = proj3d.proj_transform_clip(xs, ys, zs, renderer.M)
377+
vxs, vys, vzs, vis = proj3d.proj_transform_clip(xs, ys, zs,
378+
self.axes.M)
379379
self._path2d = mpath.Path(np.column_stack([vxs, vys]), self._code3d)
380380
# FIXME: coloring
381381
self._facecolor2d = self._facecolor3d
@@ -483,7 +483,8 @@ def set_3d_properties(self, zs, zdir):
483483

484484
def do_3d_projection(self, renderer):
485485
xs, ys, zs = self._offsets3d
486-
vxs, vys, vzs, vis = proj3d.proj_transform_clip(xs, ys, zs, renderer.M)
486+
vxs, vys, vzs, vis = proj3d.proj_transform_clip(xs, ys, zs,
487+
self.axes.M)
487488

488489
fcs = (_zalpha(self._facecolor3d, vzs) if self._depthshade else
489490
self._facecolor3d)
@@ -587,7 +588,8 @@ def set_linewidth(self, lw):
587588

588589
def do_3d_projection(self, renderer):
589590
xs, ys, zs = self._offsets3d
590-
vxs, vys, vzs, vis = proj3d.proj_transform_clip(xs, ys, zs, renderer.M)
591+
vxs, vys, vzs, vis = proj3d.proj_transform_clip(xs, ys, zs,
592+
self.axes.M)
591593

592594
fcs = (_zalpha(self._facecolor3d, vzs) if self._depthshade else
593595
self._facecolor3d)
@@ -769,7 +771,7 @@ def do_3d_projection(self, renderer):
769771
self.update_scalarmappable()
770772
self._facecolors3d = self._facecolors
771773

772-
txs, tys, tzs = proj3d._proj_transform_vec(self._vec, renderer.M)
774+
txs, tys, tzs = proj3d._proj_transform_vec(self._vec, self.axes.M)
773775
xyzlist = [(txs[sl], tys[sl], tzs[sl]) for sl in self._segslices]
774776

775777
# This extra fuss is to re-order face / edge colors
@@ -805,7 +807,7 @@ def do_3d_projection(self, renderer):
805807
# Return zorder value
806808
if self._sort_zpos is not None:
807809
zvec = np.array([[0], [0], [self._sort_zpos], [1]])
808-
ztrans = proj3d._proj_transform_vec(zvec, renderer.M)
810+
ztrans = proj3d._proj_transform_vec(zvec, self.axes.M)
809811
return ztrans[2][0]
810812
elif tzs.size > 0:
811813
# FIXME: Some results still don't look quite right.

‎lib/mpl_toolkits/mplot3d/axis3d.py

Copy file name to clipboardExpand all lines: lib/mpl_toolkits/mplot3d/axis3d.py
+8-8Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ def _get_coord_info(self, renderer):
189189
maxs = maxs + deltas / 4.
190190

191191
vals = mins[0], maxs[0], mins[1], maxs[1], mins[2], maxs[2]
192-
tc = self.axes.tunit_cube(vals, renderer.M)
192+
tc = self.axes.tunit_cube(vals, self.axes.M)
193193
avgz = [tc[p1][2] + tc[p2][2] + tc[p3][2] + tc[p4][2]
194194
for p1, p2, p3, p4 in self._PLANES]
195195
highs = np.array([avgz[2*i] < avgz[2*i+1] for i in range(3)])
@@ -237,8 +237,8 @@ def draw(self, renderer):
237237
edgep2 = edgep1.copy()
238238
edgep2[juggled[1]] = maxmin[juggled[1]]
239239
pep = np.asarray(
240-
proj3d.proj_trans_points([edgep1, edgep2], renderer.M))
241-
centpt = proj3d.proj_transform(*centers, renderer.M)
240+
proj3d.proj_trans_points([edgep1, edgep2], self.axes.M))
241+
centpt = proj3d.proj_transform(*centers, self.axes.M)
242242
self.line.set_data(pep[0], pep[1])
243243
self.line.draw(renderer)
244244

@@ -270,7 +270,7 @@ def draw(self, renderer):
270270
axmask = [True, True, True]
271271
axmask[index] = False
272272
lxyz = move_from_center(lxyz, centers, labeldeltas, axmask)
273-
tlx, tly, tlz = proj3d.proj_transform(*lxyz, renderer.M)
273+
tlx, tly, tlz = proj3d.proj_transform(*lxyz, self.axes.M)
274274
self.label.set_position((tlx, tly))
275275
if self.get_rotate_label(self.label.get_text()):
276276
angle = art3d._norm_text_angle(np.rad2deg(np.arctan2(dy, dx)))
@@ -291,7 +291,7 @@ def draw(self, renderer):
291291
outerindex = 1
292292

293293
pos = move_from_center(outeredgep, centers, labeldeltas, axmask)
294-
olx, oly, olz = proj3d.proj_transform(*pos, renderer.M)
294+
olx, oly, olz = proj3d.proj_transform(*pos, self.axes.M)
295295
self.offsetText.set_text(self.major.formatter.get_offset())
296296
self.offsetText.set_position((olx, oly))
297297
angle = art3d._norm_text_angle(np.rad2deg(np.arctan2(dy, dx)))
@@ -374,11 +374,11 @@ def draw(self, renderer):
374374
pos[tickdir] = (
375375
edgep1[tickdir]
376376
+ info['tick']['outward_factor'] * ticksign * tickdelta)
377-
x1, y1, z1 = proj3d.proj_transform(*pos, renderer.M)
377+
x1, y1, z1 = proj3d.proj_transform(*pos, self.axes.M)
378378
pos[tickdir] = (
379379
edgep1[tickdir]
380380
- info['tick']['inward_factor'] * ticksign * tickdelta)
381-
x2, y2, z2 = proj3d.proj_transform(*pos, renderer.M)
381+
x2, y2, z2 = proj3d.proj_transform(*pos, self.axes.M)
382382

383383
# Get position of label
384384
default_offset = 8. # A rough estimate
@@ -389,7 +389,7 @@ def draw(self, renderer):
389389
axmask[index] = False
390390
pos[tickdir] = edgep1[tickdir]
391391
pos = move_from_center(pos, centers, labeldeltas, axmask)
392-
lx, ly, lz = proj3d.proj_transform(*pos, renderer.M)
392+
lx, ly, lz = proj3d.proj_transform(*pos, self.axes.M)
393393

394394
tick_update_position(tick, (x1, x2), (y1, y2), (lx, ly))
395395
tick.tick1line.set_linewidth(

0 commit comments

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