Skip to content

Dashed Lines not supported since mpl 3.6.2 #567

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

Open
michi7x7 opened this issue Jan 4, 2023 · 2 comments
Open

Dashed Lines not supported since mpl 3.6.2 #567

michi7x7 opened this issue Jan 4, 2023 · 2 comments

Comments

@michi7x7
Copy link

michi7x7 commented Jan 4, 2023

Exporting a dashed line

import tikzplotlib
import matplotlib.pyplot as plt

plt.figure()
plt.plot([0, 1], [0, 1], 'k--')
tikzplotlib.get_tikz_code()

results in an error:

AttributeError: 'Line2D' object has no attribute '_us_dashSeq'

This happens because matplotlib v3.6.2 (commit-link) changed the way it handles the dash-patterns in its internal code.

@michi7x7
Copy link
Author

michi7x7 commented Jan 4, 2023

A quick fix can be implemented by Monkey-patching MPL:

from matplotlib.lines import Line2D
from matplotlib.legend import Legend
Line2D._us_dashSeq    = property(lambda self: self._dash_pattern[1])
Line2D._us_dashOffset = property(lambda self: self._dash_pattern[0])
Legend._ncol = property(lambda self: self._ncols)

The Legend-patch fixes #564

@Dotile
Copy link

Dotile commented Jan 9, 2023

Had the same issue.

Repository owner deleted a comment from st-- May 6, 2023
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

No branches or pull requests

2 participants