Can I draw three and more axes put in one plot using Bokeh?
For testing if I could, I tried the following code:
x = pd.date_range(‘2017/8/20’, periods=7, freq=‘D’)
y = list(range(len(x)))
y_cat = list(‘ABCDEFG’)
plt = figure(plot_width=800, plot_height=400,
x_axis_type=“datetime”)
plt.y_range = Range1d(-0.1,len(y)-0.8)
plt.circle(x=x, y=y ,size=5, color=“blue”, legend=‘Type1 events’)
plt.yaxis[0].ticker = FixedTicker(ticks=y)
plt.yaxis[0].major_label_overrides = dict(zip(y, y_cat))
y1 = np.random.random(len(y))*10
plt.extra_y_ranges = {‘Numeric data’: Range1d(min(y1), max(y1))}
plt.add_layout(LinearAxis(y_range_name=“Numeric data”, axis_label=‘Numeric data’), ‘left’)
plt.circle(x=x, y=y1 ,size=5, color=“red”, legend=‘Numeric data’)
#-----> Upto this point the graph is successfully rendered, where two axes are drawn. One issue though is that toolbar is overalpped with left axis when it is put to the left side of the plot)
#-----> Adding the below code to put a third y-axis produces an error
y2 = list(range(len(x)))
y2_cat = list(‘abcdefg’)
plt.extra_y_ranges = {‘Type2 events’: Range1d(-0.1, len(y2)-0.8)}
plt.add_layout(LinearAxis(y_range_name=“Type2 events”, axis_label=‘Type2 events’), ‘right’)
plt.circle(x=x, y=y2 ,size=5, color=“green”, legend=‘Type2 events’)
show(plt)
The error message is this:
W-1005 (SNAPPED_TOOLBAR_ANNOTATIONS): Snapped toolbars and annotations on the same side MAY overlap visually: Figure(id=‘dd07ba8a-bde3-4f35-88ca-9cf120919f25’, …)
TypeError: Unable to get property ‘min’ of undefined or null reference
In sum, I’ve encoutered two kind of problems
-
toolbar is overlapped with axis (when there are only two axis and toolbar is positioned at left side of the plot)
-
TypeError: Unable to get property ‘min’ of undefined or null reference when I try putting a third axis