Toggle between linear and log scale in bokeh

后端 未结 1 1185
梦谈多话
梦谈多话 2020-12-21 07:13

How can I re-generate this example toggling between linear and log scales?

Background: I\'m a long-time Matplotlib user, recent Bokeh user. One of the main reasons

相关标签:
1条回答
  • 2020-12-21 07:47

    One potential solution is the put both linear and log plots into Tabs like:

    from bokeh.plotting import figure, show
    from bokeh.models.widgets import Tabs, Panel
    
    panels = []
    
    for axis_type in ["linear", "log"]:
        fig = figure(x_axis_type=axis_type, y_axis_type=axis_type)
        fig.scatter(x=[1,10,100,1000], y=[1,10,100,1000])
    
        panel = Panel(child=fig, title=axis_type)
        panels.append(panel)
    
    tabs = Tabs(tabs=panels)
    
    show(tabs)
    

    Alternatively, you wire up a bokeh.models.widgets.Button with a CustomJS callback that changes the plot ranges, but the above seems a little easier to me.

    0 讨论(0)
提交回复
热议问题