@@ -322,10 +322,6 @@ def draw(self, renderer):
322
322
self .line .set_data (pep [0 ], pep [1 ])
323
323
self .line .draw (renderer )
324
324
325
- # Grid points where the planes meet
326
- xyz0 = np .tile (minmax , (len (ticks ), 1 ))
327
- xyz0 [:, index ] = [tick .get_loc () for tick in ticks ]
328
-
329
325
# Draw labels
330
326
# The transAxes transform is used because the Text object
331
327
# rotates the text relative to the display coordinate system.
@@ -414,10 +410,7 @@ def draw(self, renderer):
414
410
if (centpt [index ] > pep [index , outerindex ]
415
411
and np .count_nonzero (highs ) % 2 == 0 ):
416
412
# Usually mean align left, except if it is axis 2
417
- if index == 2 :
418
- align = 'right'
419
- else :
420
- align = 'left'
413
+ align = 'right' if index == 2 else 'left'
421
414
else :
422
415
# The TT case
423
416
align = 'right'
@@ -426,57 +419,61 @@ def draw(self, renderer):
426
419
self .offsetText .set_ha (align )
427
420
self .offsetText .draw (renderer )
428
421
429
- if self .axes ._draw_grid and len (ticks ):
430
- # Grid lines go from the end of one plane through the plane
431
- # intersection (at xyz0) to the end of the other plane. The first
432
- # point (0) differs along dimension index-2 and the last (2) along
433
- # dimension index-1.
434
- lines = np .stack ([xyz0 , xyz0 , xyz0 ], axis = 1 )
435
- lines [:, 0 , index - 2 ] = maxmin [index - 2 ]
436
- lines [:, 2 , index - 1 ] = maxmin [index - 1 ]
437
- self .gridlines .set_segments (lines )
438
- self .gridlines .set_color (info ['grid' ]['color' ])
439
- self .gridlines .set_linewidth (info ['grid' ]['linewidth' ])
440
- self .gridlines .set_linestyle (info ['grid' ]['linestyle' ])
441
- self .gridlines .do_3d_projection ()
442
- self .gridlines .draw (renderer )
443
-
444
- # Draw ticks:
445
- tickdir = self ._get_tickdir ()
446
- tickdelta = deltas [tickdir ]
447
- if highs [tickdir ]:
448
- ticksign = 1
449
- else :
450
- ticksign = - 1
422
+ if len (ticks ):
423
+ if self .axes ._draw_grid :
424
+ # Grid points where the planes meet
425
+ xyz0 = np .tile (minmax , (len (ticks ), 1 ))
426
+ xyz0 [:, index ] = [tick .get_loc () for tick in ticks ]
427
+
428
+ # Grid lines go from the end of one plane through the plane
429
+ # intersection (at xyz0) to the end of the other plane.
430
+ # The first point (0) differs along dimension index-2 and the
431
+ # last (2) along dimension index-1.
432
+ lines = np .stack ([xyz0 , xyz0 , xyz0 ], axis = 1 )
433
+ lines [:, 0 , index - 2 ] = maxmin [index - 2 ]
434
+ lines [:, 2 , index - 1 ] = maxmin [index - 1 ]
435
+ self .gridlines .set_segments (lines )
436
+ gridinfo = info ['grid' ]
437
+ self .gridlines .set_color (gridinfo ['color' ])
438
+ self .gridlines .set_linewidth (gridinfo ['linewidth' ])
439
+ self .gridlines .set_linestyle (gridinfo ['linestyle' ])
440
+ self .gridlines .do_3d_projection ()
441
+ self .gridlines .draw (renderer )
442
+
443
+ # Draw ticks:
444
+ tickdir = self ._get_tickdir ()
445
+ tickdelta = deltas [tickdir ]
446
+ tickdelta = tickdelta if highs [tickdir ] else - tickdelta
447
+
448
+ tick_info = info ['tick' ]
449
+ tick_out = tick_info ['outward_factor' ] * tickdelta
450
+ tick_in = tick_info ['inward_factor' ] * tickdelta
451
+ tick_lw = tick_info ['linewidth' ]
452
+ edgep1_tickdir = edgep1 [tickdir ]
453
+ out_tickdir = edgep1_tickdir + tick_out
454
+ in_tickdir = edgep1_tickdir - tick_in
451
455
452
- for tick in ticks :
453
- # Get tick line positions
454
- pos = edgep1 .copy ()
455
- pos [index ] = tick .get_loc ()
456
- pos [tickdir ] = (
457
- edgep1 [tickdir ]
458
- + info ['tick' ]['outward_factor' ] * ticksign * tickdelta )
459
- x1 , y1 , z1 = proj3d .proj_transform (* pos , self .axes .M )
460
- pos [tickdir ] = (
461
- edgep1 [tickdir ]
462
- - info ['tick' ]['inward_factor' ] * ticksign * tickdelta )
463
- x2 , y2 , z2 = proj3d .proj_transform (* pos , self .axes .M )
464
-
465
- # Get position of label
466
456
default_offset = 8. # A rough estimate
467
- labeldeltas = (
468
- (tick .get_pad () + default_offset ) * deltas_per_point * deltas )
469
-
470
- axmask = [True , True , True ]
471
- axmask [index ] = False
472
- pos [tickdir ] = edgep1 [tickdir ]
473
- pos = move_from_center (pos , centers , labeldeltas , axmask )
474
- lx , ly , lz = proj3d .proj_transform (* pos , self .axes .M )
475
-
476
- tick_update_position (tick , (x1 , x2 ), (y1 , y2 ), (lx , ly ))
477
- tick .tick1line .set_linewidth (
478
- info ['tick' ]['linewidth' ][tick ._major ])
479
- tick .draw (renderer )
457
+ points = deltas_per_point * deltas
458
+ for tick in ticks :
459
+ # Get tick line positions
460
+ pos = edgep1 .copy ()
461
+ pos [index ] = tick .get_loc ()
462
+ pos [tickdir ] = out_tickdir
463
+ x1 , y1 , z1 = proj3d .proj_transform (* pos , self .axes .M )
464
+ pos [tickdir ] = in_tickdir
465
+ x2 , y2 , z2 = proj3d .proj_transform (* pos , self .axes .M )
466
+
467
+ # Get position of label
468
+ labeldeltas = (tick .get_pad () + default_offset ) * points
469
+
470
+ pos [tickdir ] = edgep1_tickdir
471
+ pos = move_from_center (pos , centers , labeldeltas , axmask )
472
+ lx , ly , lz = proj3d .proj_transform (* pos , self .axes .M )
473
+
474
+ tick_update_position (tick , (x1 , x2 ), (y1 , y2 ), (lx , ly ))
475
+ tick .tick1line .set_linewidth (tick_lw [tick ._major ])
476
+ tick .draw (renderer )
480
477
481
478
renderer .close_group ('axis3d' )
482
479
self .stale = False
0 commit comments