Skip to content

[Bug]: Changing Linestyle in plot window swaps some plotted lines #22823

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

Closed
lucashc opened this issue Apr 11, 2022 · 3 comments · Fixed by #22208
Closed

[Bug]: Changing Linestyle in plot window swaps some plotted lines #22823

lucashc opened this issue Apr 11, 2022 · 3 comments · Fixed by #22208

Comments

@lucashc
Copy link

lucashc commented Apr 11, 2022

Bug summary

After creating a figure with multiple lines plotted using the plt.loglog() command, altering the linestyle in the plot window under Figure Options -> Curves, results in some lines being swapped.

Code for reproduction

import matplotlib.pyplot as plt
import numpy as np

Ns = np.array([10, 20, 40, 80])
errors_fd = np.array([1.30069562e-17, 1.83972081e-17, 2.66824646e-16, 8.61976660e-16])
errors_dd = np.array([8.67886156e-12, 1.57381890e-11, 1.35584771e-08, 4.95264847e-06])
errors_operator = np.array([8.67888088e-12, 1.57381914e-11, 1.35584771e-08, 4.95264847e-06])
errors_rb = np.array([5.49503157e-06, 4.64897012e-06, 4.06345733e-06, 6.20409921e-06])


plt.loglog(Ns, errors_fd, label="Finite Difference", linestyle="-.", marker=".")
plt.loglog(Ns, errors_dd, label="Domain Decomposition", linestyle="-", marker="x")
plt.loglog(Ns, errors_operator, label="Exact Poincaré-Steklov", linestyle="-.", marker=".")
plt.loglog(Ns, errors_rb, label="Reduced Basis", linestyle="-.", marker=".")
plt.loglog(Ns, 1/Ns**2, label="Reference quadratic")
plt.xlabel("$N$ (number of disretisation points)")
plt.ylabel("$L^2$-error")
plt.grid()
plt.legend()
plt.title("$L^2$-error of numerical methods")

plt.show()

Actual outcome

Outcome plot:
image

After changing the linestyle of the "Domain Decomposition" line to dotted:
image

Expected outcome

I would expect that the "Finite Difference" line and the line of "Domain Decomposition" to not swap places in the graph.

Additional information

I have edited figures before and this is the first time this bug occurs for me.
I am on quite a new version of Python using the virtual environment provided by PyCharm Community Edition (Installed using Flatpak). I also run my code from within there.

Operating system

Fedora Workstation 35

Matplotlib Version

3.5.1

Matplotlib Backend

Backend QtAgg is interactive backend. Turning interactive mode on. Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway. Gtk-Message: 15:12:47.821: Failed to load module "canberra-gtk-module" Gtk-Message: 15:12:47.821: Failed to load module "pk-gtk-module" Gtk-Message: 15:12:47.821: Failed to load module "canberra-gtk-module" Gtk-Message: 15:12:47.822: Failed to load module "pk-gtk-module" QtAgg

Python version

Python 3.9.9

Jupyter version

Not installed

Installation

pip

@oscargus
Copy link
Member

For what it is worth: I cannot seem to recreate this using main on my CentOS 7 machine. So either it is fixed or I somehow fail some step to reproduce it.

@tacaswell
Copy link
Member

This was fixed by 9622598 / #22208 and will be released in 3.5.2 (which should be out soon).

I'm going to close this as a duplicate of #22208, sorry for the difficulty. The regression came in in 3.5.0 so if falling back to 3.4 may be an option here.

@tacaswell tacaswell added this to the v3.5.2 milestone Apr 11, 2022
@tacaswell tacaswell linked a pull request Apr 11, 2022 that will close this issue
1 task
@lucashc
Copy link
Author

lucashc commented Apr 11, 2022

Thank you, that was fast.
Have a nice day!

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

Successfully merging a pull request may close this issue.

3 participants