Skip to content

Docs for contour levels argument is incorrect #12729

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ImportanceOfBeingErnest opened this issue Nov 4, 2018 · 0 comments · Fixed by #16534
Closed

Docs for contour levels argument is incorrect #12729

ImportanceOfBeingErnest opened this issue Nov 4, 2018 · 0 comments · Fixed by #16534
Assignees
Labels
Documentation Good first issue Open a pull request against these issues if there are no active ones!
Milestone

Comments

@ImportanceOfBeingErnest
Copy link
Member

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.

image

One may look at the generated levels as a function of the input argument,

image

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:

  1. Find out how many intervals MaxNLocator is capable of producing.
  2. Correct MaxNLocator docstring
  3. Based on that, correct contourf docstring.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Good first issue Open a pull request against these issues if there are no active ones!
Projects
None yet
4 participants