-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
plot_surface docstring + edge case fix #9277
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
Conversation
lib/mpl_toolkits/mplot3d/axes3d.py
Outdated
''' | ||
The *rcount* and *ccount* kwargs, which both default to 50, | ||
determine the maximum number of samples used in each direction. If | ||
the input data is larger, it will be downsampled to these numbers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might be worth saying 'downsampled by slicing' ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... I would have thought it was downsampled by averaging (well, perhaps not).
This behavior is seriously ridiculous. Anyways, fixed the doc accordingly.
lib/mpl_toolkits/mplot3d/axes3d.py
Outdated
along this direction, producing a 3D line plot rather than a | ||
wireframe plot. | ||
Added in v2.0.0. | ||
.. warning:: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you making this a warning?
""" |
This is the default sampling method unless using the 'classic' | ||
style. Will raise ValueError if both stride and count are | ||
specified. | ||
Added in v2.0.0. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fact that this kwarg was added in v2.0.0 is important. I can't tell you the number of times I run into situations where I tried using a feature in an older codebase only to discover that the feature isn't available in the older version of the package because it wasn't documented as such on the website.
sample the input data to generate the graph. If 1k by 1k | ||
arrays are passed in, the default values for the strides will | ||
result in a 100x100 grid being plotted. Defaults to 10. | ||
Raises a ValueError if both stride and count kwargs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are also lost the information that the stride and count kwargs can't be used together, and will raise a ValueError.
I'm not particularly interested in relitigating #3142, but the main point is that (regardless of whether it is a good design, and as reported in #8706) it is rathe unintuitive that a function defaults to silently discarding some of the input data (well, the only other example I can think of in mpl is #8278, where I took the same side of the discussion), and this kind of behavior should be emphasized in the docs. The fact that the count and stride arguments are mutually exclusive with each other is, well, documented in the parameter list next to rstride, cstride (I don't think mentioning the exception class is particularly relevant here, if you are so careful that you want to wrap the thing in a try... except you may as well not pass count and stride at the same time. grepping for versionadded/versionchanged in the codebase shows that it is exclusively used in mplot3d (+ 1 example, + 1 docstring of a function I backported from numpy). And even there, basically no change has been logged between 1.2 and 2.0 (rcount/ccount where added in 2.0, then voxels in 2.1), which suggests that there is probably a lot of missing version information anyways. Let's just stop pretending we're keeping that information available and up to date. |
I was mystified by this default behaviour once upon a time as well. It is indeed obvious that matplotlib is doing something to the data. On the other hand, its not at all clear that it is by design and that there are arguments to set the decimation, called |
I am not saying that it shouldn't be highlighted. I am against putting it in as a warning. If anything, make it a note. As for mutual exclusivity, I missed it in your diff, so I take that back. As for the versionadded thing, we aren't pretending anything. I have been meticulous in my maintenance of the versionadded info in mplot3d. There haven't been many new features added since I did my overhaul 5 or so years ago. Please don't remove useful information. |
I think the new version is a reasonable middle ground for everyone. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, this is a definite improvement for the docstring. Just noticed a possible typo, though.
lib/mpl_toolkits/mplot3d/axes3d.py
Outdated
rstride, cstride : int | ||
Downsampling stride in each direction. These arguments are | ||
mutually exclusive with *rcount* and *ccount*. If only one of | ||
*rcount* or *ccount* is set, the other defaults to 10. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, I think you mean If only one of *rstride* or *cstride*
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch, fixed (below too)
lib/mpl_toolkits/mplot3d/axes3d.py
Outdated
rstride, cstride : int | ||
Downsampling stride in each direction. These arguments are | ||
mutually exclusive with *rcount* and *ccount*. If only one of | ||
*rcount* or *ccount* is set, the other defaults to 1. Setting a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
…me}. Docstrings: Emphasize the downsampling. Clarify when the defaults for rstride and cstride apply. Passing an infinite rcount and ccount is the easiest way to ensure the data does not get downsampled (which I still think is a misfeature, but that's a battle for another day), but would result in a stride of zero; instead, ensure that the stride is at least 1.
@meeseeksdev backport to v2.1.x |
Backport PR #9277 on branch v2.1.x
PR Summary
Update doctrings of plot_surface & plot_wireframe.
Emphasize the downsampling. Clarify when the defaults for rstride and
cstride apply.
Allow passing infinite rcount & ccount to plot_surface, plot_wireframe.
Passing an infinite rcount and ccount is the easiest way to ensure the
data does not get downsampled (which I still think is a misfeature, but
that's a battle for another day), but would result in a stride of zero;
instead, ensure that the stride is at least 1.
Closes #8706.
PR Checklist