Closed
Description
I tried to get a contour plot of the complex angles of a particular function, but always got one level too many around zeros and infinities. Consider the following MWE which is supposed to plot the contour line for pi / 4
only. It plots pi / 4
alright, but also pi
.
import numpy as np
import matplotlib.pyplot as plt
xmin, xmax = -3.0, 3.0
ymin, ymax = -3.0, 3.0
nx, ny = 500, 500
x = np.linspace(xmin, xmax, nx)
y = np.linspace(ymin, ymax, ny)
X, Y = np.meshgrid(x, y)
fZ = np.angle(X + 1j * Y)
plt.contour(X, Y, fZ, levels=[0.25 * np.pi], colors="k")
plt.gca().set_aspect("equal")
plt.show()
This is with mpl 3.4.2.
Edit: A very similar report is on stackoverflow.