☰Read-only archive⌕
Looking for help with Bokeh?

This is a read-only archive. Ask questions and join the conversation on GitHub.

Visit Community Support on GitHub →
Archived discussions · Captured October 28, 2026

How to draw more than two axes in a plot

Community Support
Royalblue
Royalblue

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

  1. toolbar is overlapped with axis (when there are only two axis and toolbar is positioned at left side of the plot)

  2. TypeError: Unable to get property ‘min’ of undefined or null reference when I try putting a third axis

⌁   Link to post
Royalblue
Royalblue

Aha, in the light of examples in https://github.com/bokeh/bokeh/issues/2006 maybe I should have done something like :

plt.extra_y_ranges[‘second axis’]= …

plt.extra_y_ranges[‘third axis’]= …

I will try that out tommorow. :slight_smile:

···

2017-08-22 21:19 GMT+09:00 Sijun Cho royalblue.cho@gmail.com:

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

  1. toolbar is overlapped with axis (when there are only two axis and toolbar is positioned at left side of the plot)
  1. TypeError: Unable to get property ‘min’ of undefined or null reference when I try putting a third axis

–

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to bokeh+unsubscribe@continuum.io.

To post to this group, send email to bokeh@continuum.io.

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/46332f5f-d798-4d10-b584-c363f296c90f%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

⌁   Link to post

End of archived discussion · Replies are disabled