@@ -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'
@@ -427,6 +420,10 @@ def draw(self, renderer):
427
420
self .offsetText .draw (renderer )
428
421
429
422
if self .axes ._draw_grid and len (ticks ):
423
+ # Grid points where the planes meet
424
+ xyz0 = np .tile (minmax , (len (ticks ), 1 ))
425
+ xyz0 [:, index ] = [tick .get_loc () for tick in ticks ]
426
+
430
427
# Grid lines go from the end of one plane through the plane
431
428
# intersection (at xyz0) to the end of the other plane. The first
432
429
# point (0) differs along dimension index-2 and the last (2) along
@@ -435,47 +432,45 @@ def draw(self, renderer):
435
432
lines [:, 0 , index - 2 ] = maxmin [index - 2 ]
436
433
lines [:, 2 , index - 1 ] = maxmin [index - 1 ]
437
434
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' ])
435
+ gridinfo = info ['grid' ]
436
+ self .gridlines .set_color (gridinfo ['color' ])
437
+ self .gridlines .set_linewidth (gridinfo ['linewidth' ])
438
+ self .gridlines .set_linestyle (gridinfo ['linestyle' ])
441
439
self .gridlines .do_3d_projection ()
442
440
self .gridlines .draw (renderer )
443
441
444
442
# Draw ticks:
445
443
tickdir = self ._get_tickdir ()
446
- tickdelta = deltas [tickdir ]
447
- if highs [tickdir ]:
448
- ticksign = 1
449
- else :
450
- ticksign = - 1
451
-
444
+ tickdelta = deltas [tickdir ] if highs [tickdir ] else - deltas [tickdir ]
445
+
446
+ tick_info = info ['tick' ]
447
+ tick_out = tick_info ['outward_factor' ] * tickdelta
448
+ tick_in = tick_info ['inward_factor' ] * tickdelta
449
+ tick_lw = tick_info ['linewidth' ]
450
+ edgep1_tickdir = edgep1 [tickdir ]
451
+ out_tickdir = edgep1_tickdir + tick_out
452
+ in_tickdir = edgep1_tickdir - tick_in
453
+
454
+ default_label_offset = 8. # A rough estimate
455
+ points = deltas_per_point * deltas
452
456
for tick in ticks :
453
457
# Get tick line positions
454
458
pos = edgep1 .copy ()
455
459
pos [index ] = tick .get_loc ()
456
- pos [tickdir ] = (
457
- edgep1 [tickdir ]
458
- + info ['tick' ]['outward_factor' ] * ticksign * tickdelta )
460
+ pos [tickdir ] = out_tickdir
459
461
x1 , y1 , z1 = proj3d .proj_transform (* pos , self .axes .M )
460
- pos [tickdir ] = (
461
- edgep1 [tickdir ]
462
- - info ['tick' ]['inward_factor' ] * ticksign * tickdelta )
462
+ pos [tickdir ] = in_tickdir
463
463
x2 , y2 , z2 = proj3d .proj_transform (* pos , self .axes .M )
464
464
465
465
# Get position of label
466
- default_offset = 8. # A rough estimate
467
- labeldeltas = (
468
- (tick .get_pad () + default_offset ) * deltas_per_point * deltas )
466
+ labeldeltas = (tick .get_pad () + default_label_offset ) * points
469
467
470
- axmask = [True , True , True ]
471
- axmask [index ] = False
472
- pos [tickdir ] = edgep1 [tickdir ]
468
+ pos [tickdir ] = edgep1_tickdir
473
469
pos = move_from_center (pos , centers , labeldeltas , axmask )
474
470
lx , ly , lz = proj3d .proj_transform (* pos , self .axes .M )
475
471
476
472
tick_update_position (tick , (x1 , x2 ), (y1 , y2 ), (lx , ly ))
477
- tick .tick1line .set_linewidth (
478
- info ['tick' ]['linewidth' ][tick ._major ])
473
+ tick .tick1line .set_linewidth (tick_lw [tick ._major ])
479
474
tick .draw (renderer )
480
475
481
476
renderer .close_group ('axis3d' )
0 commit comments