Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6839a6d

Browse files
authored
Merge pull request #10340 from ImportanceOfBeingErnest/patch-7
update set_drawstyle
2 parents b2a9e10 + 519b6a1 commit 6839a6d

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

lib/matplotlib/lines.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff 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):

lib/matplotlib/tests/test_lines.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff 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)
134147
def test_set_line_coll_dash_image():
135148
fig = plt.figure()

0 commit comments

Comments
 (0)