Description
Bug report
Bug summary
In 2.2.3 a sentence made it into the contourf
docs saying for the levels of
contourf(x,y,z,levels, ....)
levels : int or array-like, optional
Determines the number and positions of the contour lines / regions.
If an int n, use n data intervals; i.e. draw n+1 contour lines. The level heights are automatically chosen.
The bold sentence is obviously wrong, as seen from the below image. E.g. the top right plot has n=4
specified, but it produces 5 intervals and 4 contour lines. When specifying n=5
, the same 5 intervals and 4 contour lines are produced.
One may look at the generated levels as a function of the input argument,
This is because a MaxNLocator
is used.
self.locator = ticker.MaxNLocator(N + 1, min_n_ticks=1)
The MaxNLocator
docs say
Select no more than N intervals at nice locations.
I would deduce, that the contourf
docstring should rather say
If an int n, use m data intervals, where m <= n+1; i.e. draw m-1 contour lines.
However, using different data, one may even find
locator = mticker.MaxNLocator(4+1, min_n_ticks=1)
print(len(locator.tick_values(-0.11109, 1-0.1111)))
# prints 7
locator = mticker.MaxNLocator(9+1, min_n_ticks=1)
print(len(locator.tick_values(-0.11109, 1-0.1111)))
# prints 12
which might suggest that also the MaxNLocator
docstring is wrong, and should really say
Select no more than N+1 intervals at nice locations.
But maybe other data would even produce N+x
intervals?
ToDo:
- Find out how many intervals
MaxNLocator
is capable of producing. - Correct
MaxNLocator
docstring - Based on that, correct
contourf
docstring.