Open douglas-raillard-arm opened 3 years ago
Not that it also fails with Text
Tracked down to being a matplotlib issue. When calling ax.plot()
, matplotlib is kind enough to initialize the units of the xaxis and yaxis for us. When calling ax.text()
, matplotlib does not do it and crashes instead, as this example shows.
import matplotlib as mpl
import matplotlib.pyplot as plt
ax = plt.axes()
# ax.plot indirectly initializes the units of the axis, so matplotlib knows that a==0 and b==0
# If this ax.plot() is commented-out, ax.xaxis.units is no longer initialized and matplotlib barfs
ax.plot(['a','b'], [2,3])
print(ax.xaxis.units)
ax.text('a', 2.5, "hello")
ax.xaxis.set_units()
can sort of be used, be the result is quite broken (the xtick stays numeric and the autoscaling breaks) so I'm not sure what is the best approach to that problem.
EDIT: There is a similar bug opened on matplotlib https://github.com/matplotlib/matplotlib/issues/16666
ALL software version info
holoviews 1.14.4 jupyterlab 2.3.1 matplotlib 3.4.2 bokeh 2.3.2
Description of expected behavior and the observed behavior
Labels element raises an exception on matplotlib backend when the X axis is categorical
Complete, minimal, self-contained example code that reproduces the issue
Stack traceback and/or browser JavaScript console output
Screenshots or screencasts of the bug in action
Works on bokeh as following, raises an exception on matplotlib: