The contour routine seems to produce strange results when a contour line must make a 90 degree angle. The problem is reproduced by contouring a small array with 3 rows and 5 columns. The value of the array equals zero along row 0 and along column 2 (the middle column). Contouring the 0 value does not follow this column and the first row.
Code for reproduction
import numpy as np import matplotlib.pyplot as plt N = 5 h = np.empty((3, N)) h = 0 h = np.linspace(-1, 1, N) h = np.linspace(-2, 2, N) print(h) plt.contour(h, [-1.5, -1, -0.5, 0, 0.5, 1, 1.5], colors='b') plt.contour(h, , colors='r') plt.grid()
The red line, which represents the line for which
h=0 should have gone straight down to (2,0) and then make a 90 degree angle at the bottom of the figure. In fact, the entire bottom row of the figure equals 0.
- Operating system: MacOS
- Matplotlib version 3.3.2
- Matplotlib backend MacOS
- Python version: 3.8 (standard Anaconda distribution)
- Jupyter version: Jupyter Lab 2.2.6
- Other libraries: numpy 1.19.2