-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Docs: Units example broken #5051
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
Comments
Actually, I think the problem is that the third plot has On Fri, Sep 11, 2015 at 2:48 PM, Hans Moritz Günther <
|
That's what I thought at first. I even started a PR to fix that (but did not upload it). Then I realized that there is the line
So presumably, this ax3 should show the following: We plot with unit Hertz, but then we reset the unit to minutes and the plot changes to adjust that. |
This is embarrassing. We've had a blatantly nonsensical example sitting around for years. Minimal fix: delete the third subplot. Better fix: figure out how to make the third subplot show something useful, perhaps via fixing the code in basic_units.py. |
@dopplershift, you are the units expert, right? I know you are not responsible for this example, but maybe you can figure out what to do with it. Or just rip it all out, if it is hopeless. |
Ooh, a chance to fix a 4-digit issue... |
I could put in a quick fix for this that looks like this example |
@dopplershift This example is broken for at least two reasons.
def __array__(self, dtype=object):
# return np.asarray(self.value).astype(dtype)
return np.asarray([TaggedValue(v, self.unit) for v in self.value]) This will allow some plotting functions, like |
https://matplotlib.org/stable/gallery/units/bar_unit_demo.html is also broken - bars are provided in centimetres, but then the units are converted to inches, but the numbers don't change. |
The original issue with That said, the issue with the bar chart example does appear to persist (and I think as well with changing units on scatter, but not |
This is admittedly more of a band-aid than a proper fix, but at least make the generated figure correct. The underlying problem is the more fundemental one of inconsistent units behavior in which some artists can be re-united after plotting (e.g. Line2D), while many others (e.g. Collections) cannot. Thus, until that is addressed (which is one of the goals of the data-prototype work), simply setting units early is as good as we can do. Closes matplotlib#5051
http://matplotlib.org/examples/units/units_scatter.html
shows how to use units and automatic scaling. Looking at the image, plot 2 and 3 look identical, although
ax3.yaxis.set_units(minutes)
should set the scale of the third plot to minutes. Apparently, the command changes the tick labels, but does not rescale the data.The text was updated successfully, but these errors were encountered: