FIX: Keep a dash-tuple linestyle when the figure options dialog is ac… - #32358
kunalKumar-13 wants to merge 1 commit into
Conversation
…cepted
Line2D stores a dash tuple in _unscaled_dash_pattern and reports '--' from
get_linestyle, so the Line style combobox cannot represent one. figureoptions
read that name into the combobox and wrote it straight back on OK, and
set_linestyle('--') replaces the custom pattern with the default dashed one.
Opening the dialog and clicking OK without touching anything was enough to
lose it.
Each of the four patterns from the report collapses the same way:
(0, (1, 10)) -> (0.0, (3.7, 1.6))
(5, (10, 3)) -> (0.0, (3.7, 1.6))
(0, (3, 10, 1, 10)) -> (0.0, (3.7, 1.6))
(0, (3, 5, 1, 5, 1, 5)) -> (0.0, (3.7, 1.6))
Remember what each combobox started on and only apply the selection when it
differs, so an untouched combobox leaves the line alone. Comparing against
the value prepare_data put at the head of the list rather than against
get_linestyle, since that is what the combobox actually starts on and the two
are not always spelled the same.
A line whose style really is '--' is unaffected: its dash pattern is already
the default, so skipping the write changes nothing. Picking a different entry
still applies as before. The one thing this gives up is deliberately
selecting Dashed on a line that already has a custom pattern, which the
dialog cannot express anyway - the combobox reads Dashed in both cases.
Closes matplotlib#31289
|
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. We also ask that you please finish addressing any review comments on this PR and wait for it to be merged (or closed) before opening a new one, as it can be a valuable learning experience to go through the review process. You can also join us on discourse chat for real-time discussion. For details on testing, writing docs, and our review process, please see the developer guide. We strive to be a welcoming and open project. Please follow our Code of Conduct. |
|
Hello, please review our AI policy and fill out the original Pull Request Template to let us know about your use of AI. Thank you! |
…cepted
Line2D stores a dash tuple in _unscaled_dash_pattern and reports '--' from get_linestyle, so the Line style combobox cannot represent one. figureoptions read that name into the combobox and wrote it straight back on OK, and set_linestyle('--') replaces the custom pattern with the default dashed one. Opening the dialog and clicking OK without touching anything was enough to lose it.
Each of the four patterns from the report collapses the same way:
Remember what each combobox started on and only apply the selection when it differs, so an untouched combobox leaves the line alone. Comparing against the value prepare_data put at the head of the list rather than against get_linestyle, since that is what the combobox actually starts on and the two are not always spelled the same.
A line whose style really is '--' is unaffected: its dash pattern is already the default, so skipping the write changes nothing. Picking a different entry still applies as before. The one thing this gives up is deliberately selecting Dashed on a line that already has a custom pattern, which the dialog cannot express anyway - the combobox reads Dashed in both cases.
Closes #31289
PR summary
AI Disclosure
PR quality check