File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1002,6 +1002,8 @@ def set_drawstyle(self, drawstyle):
10021002 raise ValueError ('Unrecognized drawstyle {!r}' .format (drawstyle ))
10031003 if self ._drawstyle != drawstyle :
10041004 self .stale = True
1005+ # invalidate to trigger a recache of the path
1006+ self ._invalidx = True
10051007 self ._drawstyle = drawstyle
10061008
10071009 def set_linewidth (self , w ):
Original file line number Diff line number Diff line change @@ -130,6 +130,19 @@ def test_valid_drawstyles():
130130 line .set_drawstyle ('foobar' )
131131
132132
133+ def test_set_drawstyle ():
134+ x = np .linspace (0 , 2 * np .pi , 10 )
135+ y = np .sin (x )
136+
137+ fig , ax = plt .subplots ()
138+ line , = ax .plot (x , y )
139+ line .set_drawstyle ("steps-pre" )
140+ assert len (line .get_path ().vertices ) == 2 * len (x )- 1
141+
142+ line .set_drawstyle ("default" )
143+ assert len (line .get_path ().vertices ) == len (x )
144+
145+
133146@image_comparison (baseline_images = ['line_collection_dashes' ], remove_text = True )
134147def test_set_line_coll_dash_image ():
135148 fig = plt .figure ()
You can’t perform that action at this time.
0 commit comments