Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 524a8a0

Browse filesBrowse files
authored
Merge pull request plotly#938 from nburrus/convert-dash
(matplotlylib) Make convert_dash more robust to changes in matplotlib.
2 parents cb71b64 + fafcabf commit 524a8a0
Copy full SHA for 524a8a0

File tree

Expand file treeCollapse file tree

1 file changed

+14
-2
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+14
-2
lines changed

‎plotly/matplotlylib/mpltools.py

Copy file name to clipboardExpand all lines: plotly/matplotlylib/mpltools.py
+14-2Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,21 @@ def convert_dash(mpl_dash):
5757
"""Convert mpl line symbol to plotly line symbol and return symbol."""
5858
if mpl_dash in DASH_MAP:
5959
return DASH_MAP[mpl_dash]
60-
else:
61-
return 'solid' # default
60+
else:
61+
dash_array = mpl_dash.split(',')
62+
63+
if (len(dash_array) < 2):
64+
return 'solid'
65+
66+
# Catch the exception where the off length is zero, in case
67+
# matplotlib 'solid' changes from '10,0' to 'N,0'
68+
if (math.isclose(float(dash_array[1]), 0.)):
69+
return 'solid'
6270

71+
# If we can't find the dash pattern in the map, convert it
72+
# into custom values in px, e.g. '7,5' -> '7px,5px'
73+
dashpx=','.join([x + 'px' for x in dash_array])
74+
return dashpx
6375

6476
def convert_path(path):
6577
verts = path[0] # may use this later

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.