Skip to content

Commit

Permalink
Merge pull request #5433 from tacaswell/enh_dashoffset
Browse files Browse the repository at this point in the history
ENH: pass dash_offset through to gc for Line2D
  • Loading branch information
mdboom committed Nov 24, 2015
2 parents c52ef28 + 9ee4e99 commit 06a08e3
Show file tree
Hide file tree
Showing 7 changed files with 2,896 additions and 3 deletions.
6 changes: 4 additions & 2 deletions lib/matplotlib/backends/backend_ps.py
Expand Up @@ -276,14 +276,16 @@ def set_linecap(self, linecap, store=1):
def set_linedash(self, offset, seq, store=1):
if self.linedash is not None:
oldo, oldseq = self.linedash
if seq_allequal(seq, oldseq): return
if seq_allequal(seq, oldseq) and oldo == offset:
return

if seq is not None and len(seq):
s="[%s] %d setdash\n"%(_nums_to_str(*seq), offset)
self._pswriter.write(s)
else:
self._pswriter.write("[] 0 setdash\n")
if store: self.linedash = (offset,seq)
if store:
self.linedash = (offset, seq)

def set_font(self, fontname, fontsize, store=1):
if rcParams['ps.useafm']: return
Expand Down
5 changes: 4 additions & 1 deletion lib/matplotlib/lines.py
Expand Up @@ -346,6 +346,7 @@ def __init__(self, xdata, ydata,
self.set_markersize(markersize)

self._dashSeq = None
self._dashOffset = 0

self._markeredgecolor = None
self._markeredgewidth = None
Expand Down Expand Up @@ -1028,6 +1029,7 @@ def set_linestyle(self, ls):
raise ValueError()

self.set_dashes(ls[1])
self._dashOffset = ls[0]
self._linestyle = "--"
return

Expand Down Expand Up @@ -1198,7 +1200,7 @@ def _draw_solid(self, renderer, gc, path, trans):
def _draw_dashed(self, renderer, gc, path, trans):
gc.set_linestyle('dashed')
if self._dashSeq is not None:
gc.set_dashes(0, self._dashSeq)
gc.set_dashes(self._dashOffset, self._dashSeq)

renderer.draw_path(gc, path, trans)

Expand All @@ -1222,6 +1224,7 @@ def update_from(self, other):
self._markeredgecolor = other._markeredgecolor
self._markeredgewidth = other._markeredgewidth
self._dashSeq = other._dashSeq
self._dashOffset = other._dashOffset
self._dashcapstyle = other._dashcapstyle
self._dashjoinstyle = other._dashjoinstyle
self._solidcapstyle = other._solidcapstyle
Expand Down
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 06a08e3

Please sign in to comment.