Skip to content

Preserve custom linestyles in Qt figure options#31318

Open
Raynasty66 wants to merge 1 commit intomatplotlib:mainfrom
Raynasty66:fix/qt-figureoptions-preserve-dash-tuples
Open

Preserve custom linestyles in Qt figure options#31318
Raynasty66 wants to merge 1 commit intomatplotlib:mainfrom
Raynasty66:fix/qt-figureoptions-preserve-dash-tuples

Conversation

@Raynasty66
Copy link

Fixed an issue where custom tuple dash patterns change to the unscaled dash pattern when trying to navigate off of "Edit axis, curve and image parameters"

PR summary

PR request fixes bug #31289
Currently, when a line uses any custom dash style, if one opens the qt bar option "Edit axis, curve, and image parameters", it automatically would switch the line style to a default "style token", which in this bug case was a "--"

This happened because Line2D.get_linestyle() reports a the default style token, which was tripped by the "edit axis... and image parameters" tripping set_linestyle(...) , replacing the custom tuple token. :(

PR edits figureoptions.py to where if the custom pattern and the default pattern differ, it defaults to the custom pattern specified.

AI Disclosure

AI was used to generate the test case inside test_backend_qt, labeled "test_figureoptions_preserves_custom_dash_tuple" to test if the bug was still present. All code / behavior manually reviewed by me

PR checklist

Fixed an issue where custom tuple dash patterns changes to the unscaled dash pattern when accessing "Edit axis, curve and image parameters" button
@github-actions
Copy link

Thank you for opening your first PR into Matplotlib!

If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks.

You can also join us on gitter for real-time discussion.

For details on testing, writing docs, and our review process, please see the developer guide.
Please let us know if (and how) you use AI, it will help us give you better feedback on your PR.

We strive to be a welcoming and open project. Please follow our Code of Conduct.

@Raynasty66
Copy link
Author

After checking what tests failed, I can conclude that all failures listed are not relevant to the files I edited, as this pull request only modifies figureoptions.py and tests_backend_qt.py, none of which were the cause of failure for these tests (test_backends_interactive::test_webagg and test_colorbar/test_basic follow on subprocess warnings.)

@Raynasty66 Raynasty66 marked this pull request as ready for review March 17, 2026 16:07
@timhoffm
Copy link
Member

The root cause is that get_linestyle() only returns a simplified string for dashed styles (#17316). Therefore, set_linestyle(get_linestyle()) may change the linestyle. Ideally, we would find a solution to that issue, but a local workaround for the dialog is also acceptable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants