Skip to content
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

Matplotlib version >> 3.6.2, gives AttributeError: 'Line2D' object has no attribute '_us_dashSeq' #580

Open
VijayN10 opened this issue Apr 3, 2023 · 11 comments · May be fixed by #590
Open

Comments

@VijayN10
Copy link

VijayN10 commented Apr 3, 2023

I was unable to save the plot as a TikZ file after upgrading to latest version of matplotlib. It was giving an error of
AttributeError: 'Line2D' object has no attribute '_us_dashSeq'

For plotting, I was using the following code. The error was identified with line style and markevery function.

line_styles = ['-', '--', '-.', ':', '-']
markers = ['o', 's', '^', '*', 'd']

plt.plot(x_sph_dp1, y_sph_dp1, label='dp = 0.2', color='red', linestyle=line_styles[0], marker=markers[0], linewidth=2, markevery=(0, 10))
plt.plot(x_sph_dp2, y_sph_dp2, label='dp = 0.1', color='orange', linestyle=line_styles[1], marker=markers[1], linewidth=2, markevery=(0, 10))
plt.plot(x_sph_dp2, y_sph_dp2, label='dp = 0.05', color='orange', linestyle=line_styles[2], marker=markers[2], linewidth=2, markevery=(0, 10))
plt.plot(x_exp, y_exp, label='Experiment', color='blue', linestyle=line_styles[3], marker=markers[3], linewidth=2, markevery=(0, 2))
plt.plot(x_vof, y_vof, label='VOF', color='green', linestyle=line_styles[4], marker=markers[4], linewidth=2, markevery=(0, 2))
@VijayN10
Copy link
Author

VijayN10 commented Apr 3, 2023

After downgrading to Matplotlib version 3.5.1, the problem has been resolved.

But is there any other way? Please let me know. Thank you..

@FriedrichFroebel
Copy link

This has been changed in matplotlib version 3.6.0 and needs a corresponding fix/PR.

Upstream change: matplotlib/matplotlib#21050

Repository owner deleted a comment from st-- May 6, 2023
@nyngwang
Copy link

@FriedrichFroebel Is there any workaround for this?

@FriedrichFroebel
Copy link

I have not tested this, but replacing

dashSeq = line._us_dashSeq
dashOffset = line._us_dashOffset
with

        dashOffset, dashSeq = line._unscaled_dash_pattern

might work given https://github.com/matplotlib/matplotlib/pull/21050/files#diff-be677869a88f58790f2387fb2ac0ae12e2e9610d7c7096e25d3087d5ed9645c8L1133-R1121

@sbiser
Copy link

sbiser commented Jul 24, 2023

Solution presented by @FriedrichFroebel works just fine, I've just tested it successfully.

@VijayN10
Copy link
Author

Thanks @FriedrichFroebel , its working for me as well! I hope it will be incorporated in next release.
I am closing this issue now.

@FriedrichFroebel
Copy link

@VijayN10 I do not think that it really makes sense to close this issue while there is no upstream solution for it. For now, there is no corresponding PR to ensure that once this library is finally receiving some more maintenance again this will have an official fix.

@nschloe nschloe reopened this Jul 26, 2023
@VijayN10
Copy link
Author

@nschloe , @FriedrichFroebel - Okay. Thanks.

@marko-pi
Copy link

marko-pi commented May 1, 2024

Since it is next to impossible to install matplotlib <=3.6, the tikzplotlib package is useless. It would only be fair to remove it from the package list on PyPI.

@FriedrichFroebel
Copy link

FriedrichFroebel commented May 1, 2024

I do not consider it impossible to install matplotlib<3.6.0 - at least a rather basic Ubuntu 22.04 installation (still supported until 2027) does not seem to have any issues with it. Issues might arise with further libraries requiring more recent matplotlib versions, but matplotlib core functionality should (in theory) not really be affected at all if your own code is compatible enough. (I do not like the tikzplotlib situation either, but I hate reading false claims.) For the same reason, removing the package from PyPI is even more uncommon/worse as it breaks tikzplotlib for everyone and there surely are tons of PyPI packages which have been unmaintained for sometimes more than 10 years.

@marko-pi
Copy link

marko-pi commented May 1, 2024

I tried to install matplotlib 3.5 on my Windows system with python.org distribution. After overcoming several hurdles and losing several hours, I finally failed. Well, now I have gone back to exporting PDFs and loading them into Latex files.

I started using tikzplotlib about two years ago and regret that decision because of all the extra problems. I am not an expert on Python packages and perhaps they should all continue to be available, but it would be fair if potential users were warned of the pitfalls that can occur when using tikzplotlib.

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 a pull request may close this issue.

6 participants