-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
ax.bar doesn't work correctly when width is a timedelta64 object #11290
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
Can you provide the full example with the |
@dstansby - the full example is: import numpy as np
import matplotlib.pyplot as plt
x = np.array(range(100), dtype='M8[D]')
ax = plt.subplot(1,1,1)
y = np.random.random(100)
ax.bar(x[:-1], y[:-1], width=np.diff(x)) |
The problem is our unit conversion. We do
However, we don't have a conversion implemented for The solution would be to implement a converter for |
Ah, so this would be fixed by something like #9120 I think. |
Sort of. It needs a bit more infrastructure:
|
I'm having a look at this now, but having trouble with your example @astrofrog ; when I do import numpy as np
x = np.array(range(100), dtype='M8[D]')
print((x[:-1] + np.diff(x) / 2.0) - x[:-1]) I just get a bunch of zeros; dividing |
|
Trying to take that approach, but running into the problem that import numpy as np
import matplotlib.pyplot as plt
import matplotlib.units as munits
x = np.array(range(100), dtype='M8[D]')
xdiff = np.diff(x)
print(xdiff.dtype)
print(munits.ConversionInterface.is_numlike(xdiff)) prints timedelta64[D]
True |
The following example
works fine, but if I set width to be the diff of the
datetime64
array, which gives atimedelta64
array, things break:This should however be unambiguous, so it would be nice if it worked.
The text was updated successfully, but these errors were encountered: