Closed
Description
Alerted to by @anntzer in #9350, the fill_between with all categorical doesn't do an update on the y2 and so the following code:
plt.fill_between(['a', 'b', 'c'], ['e', 'f', 'g'],['h','i','j'])
Crashes on the lookup:
/projects/matplotlib/lib/matplotlib/artist.py in convert_yunits(self, y)
198 if ax is None or ax.yaxis is None:
199 return y
--> 200 return ax.yaxis.convert_units(y)
201
202 @property
~/projects/matplotlib/lib/matplotlib/axis.py in convert_units(self, x)
1489 return x
1490
-> 1491 ret = self.converter.convert(x, self.units, self)
1492 return ret
1493
This seems to be limited to categoricals because dates work as expected:
import numpy as np
import pandas as pd
dates = pd.date_range('1990-10-10', '2004-10-10', freq='M')
x = np.arange(84)
y1 = dates[:84]
y2 = dates[84:]
plt.fill_between(x, y2, y1)
And as @anntzer suggested, the axis behavior should be modified such that once units are set on that axis, the axis should error out if new input isn't in the same units. As expected, the following errors out: plt.fill_between(x, x, y1)