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