Skip to content

Commit 4395e2c

Browse files
committed
Fix line dash offset format in PS output
1 parent ad66238 commit 4395e2c

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lib/matplotlib/backends/backend_ps.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,8 @@ def set_linedash(self, offset, seq, store=True):
329329
if np.array_equal(seq, oldseq) and oldo == offset:
330330
return
331331

332-
self._pswriter.write(f"[{_nums_to_str(*seq)}] {offset:d} setdash\n"
332+
self._pswriter.write(f"[{_nums_to_str(*seq)}]"
333+
f" {_nums_to_str(offset)} setdash\n"
333334
if seq is not None and len(seq) else
334335
"[] 0 setdash\n")
335336
if store:

lib/matplotlib/tests/test_backend_ps.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,3 +222,15 @@ def test_fonttype(fonttype):
222222
test = b'/FontType ' + bytes(f"{fonttype}", encoding='utf-8') + b' def'
223223

224224
assert re.search(test, buf.getvalue(), re.MULTILINE)
225+
226+
227+
def test_linedash():
228+
"""Test that dashed lines do not break PS output"""
229+
fig, ax = plt.subplots()
230+
231+
ax.plot([0, 1], linestyle="--")
232+
233+
buf = io.BytesIO()
234+
fig.savefig(buf, format="ps")
235+
236+
assert buf.tell() > 0

0 commit comments

Comments
 (0)