You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ax.bar() fails if the input data has units. This is a fairly new bug as it worked fine at some point in the past. The exception is:
/home/trd/work/git/matplotlib/build/lib.linux-x86_64-3.6/matplotlib/axes/_base.py:2500: RuntimeWarning: invalid value encountered in double_scalars
delta = (x1t - x0t) * margin
The issue is that the unit conversion code is being run after a call to np.broadcast_arrays so that the x values are not actually arrays, they're still lists of units. The fix is re-order the code in bar() so that the unit conversion happens first.
Code for reproduction
I'll send in a pull request w/ a fix once I can get the right version of free type to install so I can run existing tests and create a baseline file. This occurs on the current master branch code.
New test case being added to test_units.py which will throw the exception:
@image_comparison(baseline_images=['jpl_bar_units'], extensions=['png'],
savefig_kwarg={'dpi': 60})
def test_jpl_bar_units():
from datetime import datetime
import matplotlib.testing.jpl_units as units
units.register()
day = units.Duration("ET", 24.0 * 60.0 * 60.0)
x = [units.Epoch("ET", dt=datetime(2009, 4, 25)),
units.Epoch("ET", dt=datetime(2009, 4, 26)),
units.Epoch("ET", dt=datetime(2009, 4, 27))]
width = [3*day, 2*day, 1*day]
fig, ax = plt.subplots()
ax.bar(x, width)
The text was updated successfully, but these errors were encountered:
Bug report
ax.bar() fails if the input data has units. This is a fairly new bug as it worked fine at some point in the past. The exception is:
The issue is that the unit conversion code is being run after a call to np.broadcast_arrays so that the x values are not actually arrays, they're still lists of units. The fix is re-order the code in bar() so that the unit conversion happens first.
Code for reproduction
I'll send in a pull request w/ a fix once I can get the right version of free type to install so I can run existing tests and create a baseline file. This occurs on the current master branch code.
New test case being added to test_units.py which will throw the exception:
The text was updated successfully, but these errors were encountered: