@@ -240,11 +240,8 @@ def draw(self, renderer):
240
240
self .line .draw (renderer )
241
241
242
242
# Grid points where the planes meet
243
- xyz0 = []
244
- for tick in ticks :
245
- coord = minmax .copy ()
246
- coord [index ] = tick .get_loc ()
247
- xyz0 .append (coord )
243
+ xyz0 = np .tile (minmax , (len (ticks ), 1 ))
244
+ xyz0 [:, index ] = [tick .get_loc () for tick in ticks ]
248
245
249
246
# Draw labels
250
247
peparray = np .asanyarray (pep )
@@ -350,30 +347,25 @@ def draw(self, renderer):
350
347
self .offsetText .draw (renderer )
351
348
352
349
# Draw grid lines
353
- if len (xyz0 ) > 0 :
350
+ if self . axes . _draw_grid and len (ticks ) :
354
351
# Grid points at end of one plane
355
- xyz1 = copy . deepcopy ( xyz0 )
352
+ xyz1 = xyz0 . copy ( )
356
353
newindex = (index + 1 ) % 3
357
354
newval = get_flip_min_max (xyz1 [0 ], newindex , mins , maxs )
358
- for i in range (len (ticks )):
359
- xyz1 [i ][newindex ] = newval
355
+ xyz1 [:, newindex ] = newval
360
356
361
357
# Grid points at end of the other plane
362
- xyz2 = copy . deepcopy ( xyz0 )
358
+ xyz2 = xyz0 . copy ( )
363
359
newindex = (index + 2 ) % 3
364
360
newval = get_flip_min_max (xyz2 [0 ], newindex , mins , maxs )
365
- for i in range (len (ticks )):
366
- xyz2 [i ][newindex ] = newval
367
-
368
- lines = list (zip (xyz1 , xyz0 , xyz2 ))
369
- if self .axes ._draw_grid :
370
- self .gridlines .set_segments (lines )
371
- self .gridlines .set_color ([info ['grid' ]['color' ]] * len (lines ))
372
- self .gridlines .set_linewidth (
373
- [info ['grid' ]['linewidth' ]] * len (lines ))
374
- self .gridlines .set_linestyle (
375
- [info ['grid' ]['linestyle' ]] * len (lines ))
376
- self .gridlines .draw (renderer , project = True )
361
+ xyz2 [:, newindex ] = newval
362
+
363
+ lines = np .stack ([xyz1 , xyz0 , xyz2 ], axis = 1 )
364
+ self .gridlines .set_segments (lines )
365
+ self .gridlines .set_color (info ['grid' ]['color' ])
366
+ self .gridlines .set_linewidth (info ['grid' ]['linewidth' ])
367
+ self .gridlines .set_linestyle (info ['grid' ]['linestyle' ])
368
+ self .gridlines .draw (renderer , project = True )
377
369
378
370
# Draw ticks
379
371
tickdir = info ['tickdir' ]
0 commit comments