☰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

Vbar and scatter in sample - update both y-axes

Community Support
jorge
jorge

I am building a plot with two y-axes and customJS for an standalone document.
I need to have both axes to change with the selections from two drop down menus.
The left y-axis changes if I do not set the y-range in the vbar, but the other (a scattered plot) does not let me leave y-range empty. Therefore it does not changes when selected another option in menu

I have this:

    comp_bar = figure(x_range = states,  plot_width = 700, plot_height = 400 , tools = ['box_zoom, pan, save, reset, wheel_zoom'])

    comp_bar.vbar(x = dodge('x', 0, range = comp_bar.x_range), top = 'y', width = 1, source = source, alpha = 1, color = 'darkviolet', bottom=10)

    y_column_ext_range = 'new_axis'
    max_ext_accts = comp_data.y.max()
    comp_bar.extra_y_ranges = {y_column_ext_range: Range1d(start = 0,end = max_ext_accts, bounds=('auto'))}
    comp_bar.add_layout(LinearAxis(y_range_name = 'new_axis', axis_label = 'Competitor'), 'right')
    comp_bar.scatter('x', 'y', legend = 'Competitor2', line_width = 1, y_range_name = y_column_ext_range,
        color = 'blue', source = source )

    customJS1 = JS CODE
    customJS2 = JS CODE

    ext_drop_menu = Select(title="date", value = months_[0], options = months_, callback = customJS1, width = 200)
    com_drop_menu = Select(title="Competitor:", value = 'customer1', options = customers, callback = customJS2, width = 200)
    show(comp_bar, com_drop_menu, ext_drop_menu)

Thanks,

⌁   Link to post
Bryan
Bryan

Hi @jorge I am afraid it’s not clear from your description what you are trying to achieve, and there is not enough code to speculate. E.g. I can’t tell whether you mean two axes displayed at the same time (one one plot?) Or whether you want to switch/alternate between two plots but only see one at a time. Please provide a more details description of the interaction you are seeking. Some images or diagrams could really help, and certainly more code would really help.

⌁   Link to post
jorge
jorge

@Bryan I have one graph with two axes. Left axis is a bar plot in the scale of Millions. Right is an scattered plot with data in the hundreds. If I set max y for both plots the axis scale will not adjust to the filters in the drop menu. If I do not set the ymax limit, both axes change with the filters and the scattered basically become a line in the bottom.

⌁   Link to post
Bryan
Bryan

You will need to compute and set range start/end yourself. Default auto-ranging behavior is to always keep the original relative scale off the two axes in sync (e.g so that panning and zooming interactively changes both axes together). It seems like now that other use cases are possible it could make sense to offer an option to relax this constraint. A GitHub issue would be appropriate.

⌁   Link to post

End of archived discussion · Replies are disabled