@@ -237,13 +237,22 @@ class Line2D(Artist):
237
237
'steps' : '_draw_steps_pre' ,
238
238
}
239
239
240
+ # drawStyles should now be deprecated.
240
241
drawStyles = {}
241
242
drawStyles .update (_drawStyles_l )
242
243
drawStyles .update (_drawStyles_s )
243
244
# Need a list ordered with long names first:
244
245
drawStyleKeys = (list (six .iterkeys (_drawStyles_l )) +
245
246
list (six .iterkeys (_drawStyles_s )))
246
247
248
+ _drawstyle_conv = {
249
+ 'default' : lambda x , y : (x , y ),
250
+ 'steps' : pts_to_prestep ,
251
+ 'steps-pre' : pts_to_prestep ,
252
+ 'steps-mid' : pts_to_midstep ,
253
+ 'steps-post' : pts_to_poststep
254
+ }
255
+
247
256
# Referenced here to maintain API. These are defined in
248
257
# MarkerStyle
249
258
markers = MarkerStyle .markers
@@ -470,8 +479,7 @@ def contains(self, mouseevent):
470
479
# application has set the error flags such that an exception is raised
471
480
# on overflow, we temporarily set the appropriate error flags here and
472
481
# set them back when we are finished.
473
- olderrflags = np .seterr (all = 'ignore' )
474
- try :
482
+ with np .errstate (all = 'ignore' ):
475
483
# Check for collision
476
484
if self ._linestyle in ['None' , None ]:
477
485
# If no line, return the nearby point(s)
@@ -480,20 +488,9 @@ def contains(self, mouseevent):
480
488
else :
481
489
# If line, return the nearby segment(s)
482
490
ind = segment_hits (mouseevent .x , mouseevent .y , xt , yt , pixels )
483
- finally :
484
- np .seterr (** olderrflags )
485
491
486
492
ind += self .ind_offset
487
493
488
- # Debugging message
489
- if False and self ._label != '' :
490
- print ("Checking line" , self ._label ,
491
- "at" , mouseevent .x , mouseevent .y )
492
- print ('xt' , xt )
493
- print ('yt' , yt )
494
- #print 'dx,dy', (xt-mouseevent.x)**2., (yt-mouseevent.y)**2.
495
- print ('ind' , ind )
496
-
497
494
# Return the point(s) within radius
498
495
return len (ind ) > 0 , dict (ind = ind )
499
496
@@ -691,7 +688,8 @@ def recache(self, always=False):
691
688
interpolation_steps = self ._path ._interpolation_steps
692
689
else :
693
690
interpolation_steps = 1
694
- self ._path = Path (self ._xy , None , interpolation_steps )
691
+ xy = self ._drawstyle_conv [self ._drawstyle ](* self ._xy .T )
692
+ self ._path = Path (np .asarray (xy ).T , None , interpolation_steps )
695
693
self ._transformed_path = None
696
694
self ._invalidx = False
697
695
self ._invalidy = False
@@ -764,8 +762,6 @@ def draw(self, renderer):
764
762
tpath , affine = transf_path .get_transformed_path_and_affine ()
765
763
if len (tpath .vertices ):
766
764
self ._lineFunc = getattr (self , funcname )
767
- funcname = self .drawStyles .get (self ._drawstyle , '_draw_lines' )
768
- drawFunc = getattr (self , funcname )
769
765
gc = renderer .new_gc ()
770
766
self ._set_gc_clip (gc )
771
767
@@ -788,7 +784,7 @@ def draw(self, renderer):
788
784
if self .get_sketch_params () is not None :
789
785
gc .set_sketch_params (* self .get_sketch_params ())
790
786
791
- drawFunc (renderer , gc , tpath , affine .frozen ())
787
+ self . _draw_lines (renderer , gc , tpath , affine .frozen ())
792
788
gc .restore ()
793
789
794
790
if self ._marker and self ._markersize > 0 :
@@ -1234,27 +1230,6 @@ def set_dashes(self, seq):
1234
1230
def _draw_lines (self , renderer , gc , path , trans ):
1235
1231
self ._lineFunc (renderer , gc , path , trans )
1236
1232
1237
- def _draw_steps_pre (self , renderer , gc , path , trans ):
1238
- steps = np .vstack (pts_to_prestep (* self ._xy .T )).T
1239
-
1240
- path = Path (steps )
1241
- path = path .transformed (self .get_transform ())
1242
- self ._lineFunc (renderer , gc , path , IdentityTransform ())
1243
-
1244
- def _draw_steps_post (self , renderer , gc , path , trans ):
1245
- steps = np .vstack (pts_to_poststep (* self ._xy .T )).T
1246
-
1247
- path = Path (steps )
1248
- path = path .transformed (self .get_transform ())
1249
- self ._lineFunc (renderer , gc , path , IdentityTransform ())
1250
-
1251
- def _draw_steps_mid (self , renderer , gc , path , trans ):
1252
- steps = np .vstack (pts_to_midstep (* self ._xy .T )).T
1253
-
1254
- path = Path (steps )
1255
- path = path .transformed (self .get_transform ())
1256
- self ._lineFunc (renderer , gc , path , IdentityTransform ())
1257
-
1258
1233
def _draw_solid (self , renderer , gc , path , trans ):
1259
1234
gc .set_linestyle ('solid' )
1260
1235
renderer .draw_path (gc , path , trans )
0 commit comments