Skip to content

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

Closed

Description

@lucashc

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

Activity

  1. oscargus commented on Apr 11, 2022

    @oscargus
    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.

  2. tacaswell commented on Apr 11, 2022

    @tacaswell
    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.

  3. added this to the v3.5.2 milestone on Apr 11, 2022
  4. lucashc commented on Apr 11, 2022

    @lucashc
    Author

    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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions