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

Skip to content

Commit 50aceb5

Browse files
committed
ENH: pass dash_offset through to gc for Line2D
Previously, the user supplied offset to Line2D set_linestyle was silently discarded. This commit makes the value to be passed through to the underlying GC on draw, but not all of the backends do anything with the offset (ex Agg does not).
1 parent c52ef28 commit 50aceb5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/matplotlib/lines.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ def __init__(self, xdata, ydata,
346346
self.set_markersize(markersize)
347347

348348
self._dashSeq = None
349+
self._dashOffset = 0
349350

350351
self._markeredgecolor = None
351352
self._markeredgewidth = None
@@ -1028,6 +1029,7 @@ def set_linestyle(self, ls):
10281029
raise ValueError()
10291030

10301031
self.set_dashes(ls[1])
1032+
self._dashOffset = ls[0]
10311033
self._linestyle = "--"
10321034
return
10331035

@@ -1198,7 +1200,7 @@ def _draw_solid(self, renderer, gc, path, trans):
11981200
def _draw_dashed(self, renderer, gc, path, trans):
11991201
gc.set_linestyle('dashed')
12001202
if self._dashSeq is not None:
1201-
gc.set_dashes(0, self._dashSeq)
1203+
gc.set_dashes(self._dashOffset, self._dashSeq)
12021204

12031205
renderer.draw_path(gc, path, trans)
12041206

@@ -1222,6 +1224,7 @@ def update_from(self, other):
12221224
self._markeredgecolor = other._markeredgecolor
12231225
self._markeredgewidth = other._markeredgewidth
12241226
self._dashSeq = other._dashSeq
1227+
self._dashOffset = other._dashOffset
12251228
self._dashcapstyle = other._dashcapstyle
12261229
self._dashjoinstyle = other._dashjoinstyle
12271230
self._solidcapstyle = other._solidcapstyle

0 commit comments

Comments
 (0)