Closed
Description
According to the docstring, plt.contour(X, Y, Z, N)
should "contour N automatically-chosen levels".
The actual results are somewhat surprising:
import numpy as np
import matplotlib.pyplot as plt
np.random.seed(0)
xx, yy = np.mgrid[-3:3:, -3:3]
for _ in xrange(10):
zz = np.random.randn(6, 6)
cset = plt.contour(xx, yy, zz, 9)
print(len(cset.levels)),
prints 9 9 8 8 9 9 8 8 9 9
.
Additionally, the docstring for plt.contourf
has the same prose, but adds some more confusing behavior:
for _ in xrange(10):
zz = np.random.randn(6, 6)
cset = plt.contourf(xx, yy, zz, 9)
print(len(cset.levels)),
prints 11 10 11 10 10 11 10 11 11 11
(note that the N
is the same as for the contour
call above).
Am I missing something, or is this is a bug?