Skip to content

(matplotlylib) Make convert_dash more robust to changes in matplotlib. #938

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 1, 2018
Merged

(matplotlylib) Make convert_dash more robust to changes in matplotlib. #938

merged 1 commit into from
Mar 1, 2018

Conversation

nburrus
Copy link

@nburrus nburrus commented Feb 18, 2018

Now handles the case where the dashes are scaled, have floating-point values, or were customized with dashes=(N,M).

Additional context: I was trying to use mpl_to_plotly in a jupyter notebook (python 3.6.3, matplotlib 2.1.2), and converting a plot with a non-solid line style (e.g linestyle='--') would still return a solid plot. It turns out that the DASH_MAP in mpl_tools.py has a set of hardcoded values, which I imagine changed with recent versions of matplotlib.

With linestyle='--', I was getting values like '7.4,3.2' which would not match the 6,6 of the match. Forcing dash=(6,6) would still not work because the mpl_dash string would become '6.0,6.0`, and still not match '6,6'.

I am new to plotly and matplotlib, so maybe I missed something, but this PR solves the issue for me, and all the line styles are now kept during the conversion, including custom dashes. It should also be somewhat robust to future changes.

Now handles the case where the dashes are scaled, have floating-point values, or were customized with `dashes=(N,M)`.
@jackparmer
Copy link
Contributor

👍 LGTM. Thanks for taking the time to contribute.

@jackparmer jackparmer merged commit 524a8a0 into plotly:master Mar 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants