8000 Allow mplot3d rasterization; adjacent cleanups. · matplotlib/matplotlib@e127653 · GitHub
[go: up one dir, main page]

Skip to content

Commit e127653

Browse files
committed
Allow mplot3d rasterization; adjacent cleanups.
1 parent 3bb328f commit e127653

File tree

3 files changed

+26
-29
lines changed

3 files changed

+26
-29
lines changed

lib/mpl_toolkits/mplot3d/art3d.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ def set_3d_properties(self, z=0, zdir='z'):
8080
self._dir_vec = get_dir_vector(zdir)
8181
self.stale = True
8282

83+
@artist.allow_rasterization
8384
def draw(self, renderer):
8485
proj = proj3d.proj_trans_points(
8586
[self._position3d, self._position3d + self._dir_vec], renderer.M)
@@ -128,6 +129,7 @@ def set_3d_properties(self, zs=0, zdir='z'):
128129
self._verts3d = juggle_axes(xs, ys, zs, zdir)
129130
self.stale = True
130131

132+
@artist.allow_rasterization
131133
def draw(self, renderer):
132134
xs3d, ys3d, zs3d = self._verts3d
133135
xs, ys, zs = proj3d.proj_transform(xs3d, ys3d, zs3d, renderer.M)
@@ -233,6 +235,7 @@ def do_3d_projection(self, renderer):
233235
minz = min(minz, min(zs))
234236
return minz
235237

238+
@artist.allow_rasterization
236239
def draw(self, renderer, project=False):
237240
if project:
238241
self.do_3d_projection(renderer)
@@ -278,9 +281,6 @@ def do_3d_projection(self, renderer):
278281
self._facecolor2d = self._facecolor3d
279282
return min(vzs)
280283

281-
def draw(self, renderer):
282-
Patch.draw(self, renderer)
283-
284284

285285
class PathPatch3D(Patch3D):
286286
'''
@@ -704,9 +704,6 @@ def get_edgecolors(self):
704704
return self._edgecolors2d
705705
get_edgecolor = get_edgecolors
706706

707-
def draw(self, renderer):
708-
return Collection.draw(self, renderer)
709-
710707

711708
def poly_collection_2d_to_3d(col, zs=0, zdir='z'):
712709
"""Convert a PolyCollection to a Poly3DCollection object."""

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import numpy as np
2323

24+
from matplotlib import artist
2425
import matplotlib.axes as maxes
2526
import matplotlib.cbook as cbook
2627
import matplotlib.collections as mcoll
@@ -250,6 +251,7 @@ def tunit_edges(self, vals=None, M=None):
250251
(tc[7], tc[4])]
251252
return edges
252253

254+
@artist.allow_rasterization
253255
def draw(self, renderer):
254256
# draw the background patch
255257
self.patch.draw(renderer)

lib/mpl_toolkits/mplot3d/axis3d.py

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@
77

88
import six
99

10-
import math
1110
import copy
1211

13-
from matplotlib import lines as mlines, axis as maxis, patches as mpatches
14-
from matplotlib import rcParams
15-
from . import art3d
16-
from . import proj3d
12+
from matplotlib import (
13+
artist, lines as mlines, axis as maxis, patches as mpatches, rcParams)
14+
from . import art3d, proj3d
1715

1816
import numpy as np
1917

@@ -223,6 +221,7 @@ def draw_pane(self, renderer):
223221

224222
renderer.close_group('pane3d')
225223

224+
@artist.allow_rasterization
226225
def draw(self, renderer):
227226
self.label._transform = self.axes.transData
228227
renderer.open_group('axis3d')
@@ -300,31 +299,30 @@ def draw(self, renderer):
300299
renderer.M)
301300
self.label.set_position((tlx, tly))
302301
if self.get_rotate_label(self.label.get_text()):
303-
angle = art3d.norm_text_angle(math.degrees(math.atan2(dy, dx)))
302+
angle = art3d.norm_text_angle(np.rad2deg(np.arctan2(dy, dx)))
304303
self.label.set_rotation(angle)
305304
self.label.set_va(info['label']['va'])
306305
self.label.set_ha(info['label']['ha'])
307306
self.label.draw(renderer)
308307

309-
310308
# Draw Offset text
311309

312310
# Which of the two edge points do we want to
313311
# use for locating the offset text?
314-
if juggled[2] == 2 :
312+
if juggled[2] == 2:
315313
outeredgep = edgep1
316314
outerindex = 0
317-
else :
315+
else:
318316
outeredgep = edgep2
319317
outerindex = 1
320318

321319
pos = copy.copy(outeredgep)
322320
pos = move_from_center(pos, centers, labeldeltas, axmask)
323321
olx, oly, olz = proj3d.proj_transform(
324322
pos[0], pos[1], pos[2], renderer.M)
325-
self.offsetText.set_text( self.major.formatter.get_offset() )
326-
self.offsetText.set_position( (olx, oly) )
327-
angle = art3d.norm_text_angle(math.degrees(math.atan2(dy, dx)))
323+
self.offsetText.set_text(self.major.formatter.get_offset())
324+
self.offsetText.set_position((olx, oly))
325+
angle = art3d.norm_text_angle(np.rad2deg(np.arctan2(dy, dx)))
328326
self.offsetText.set_rotation(angle)
329327
# Must set rotation mode to "anchor" so that
330328
# the alignment point is used as the "fulcrum" for rotation.
@@ -345,29 +343,29 @@ def draw(self, renderer):
345343
# Three-letters (e.g., TFT, FTT) are short-hand for the array of bools
346344
# from the variable 'highs'.
347345
# ---------------------------------------------------------------------
348-
if centpt[info['tickdir']] > peparray[info['tickdir'], outerindex] :
346+
if centpt[info['tickdir']] > peparray[info['tickdir'], outerindex]:
349347
# if FT and if highs has an even number of Trues
350348
if (centpt[index] <= peparray[index, outerindex]
351-
and ((len(highs.nonzero()[0]) % 2) == 0)) :
349+
and ((len(highs.nonzero()[0]) % 2) == 0)):
352350
# Usually, this means align right, except for the FTT case,
353351
# in which offset for axis 1 and 2 are aligned left.
354-
if highs.tolist() == [False, True, True] and index in (1, 2) :
352+
if highs.tolist() == [False, True, True] and index in (1, 2):
355353
align = 'left'
356-
else :
354+
else:
357355
align = 'right'
358-
else :
356+
else:
359357
# The FF case
360358
align = 'left'
361-
else :
359+
else:
362360
# if TF and if highs has an even number of Trues
363361
if (centpt[index] > peparray[index, outerindex]
364-
and ((len(highs.nonzero()[0]) % 2) == 0)) :
362+
and len(highs.nonzero()[0]) % 2 == 0):
365363
# Usually mean align left, except if it is axis 2
366-
if index == 2 :
364+
if index == 2:
367365
align = 'right'
368-
else :
366+
else:
369367
align = 'left'
370-
else :
368+
else:
371369
# The TT case
372370
align = 'right'
373371

@@ -462,7 +460,7 @@ def set_view_interval(self, vmin, vmax, ignore=False):
462460

463461
# TODO: Get this to work properly when mplot3d supports
464462
# the transforms framework.
465-
def get_tightbbox(self, renderer) :
463+
def get_tightbbox(self, renderer):
466464
# Currently returns None so that Axis.get_tightbbox
467465
# doesn't return junk info.
468466
return None

0 commit comments

Comments
 (0)
0