使用Bokeh的散射函数记录比例

时间:2014-07-29 21:08:44

标签: python bokeh

使用Bokeh的scatter功能时,如何获取日志比例。我正在寻找以下内容:

scatter(x, y, source=my_source, ylog=True)

scatter(x, y, source=my_source, yscale='log')

1 个答案:

答案 0 :(得分:20)

沿着这些方向的东西将起作用:

import numpy as np
from bokeh.plotting import *

N = 100

x = np.linspace(0.1, 5, N)

output_file("logscatter.html", title="log axis scatter example")

figure(tools="pan,wheel_zoom,box_zoom,reset,previewsave",
       y_axis_type="log", y_range=[0.1, 10**2], title="log axis scatter example")

scatter(x, np.sqrt(x), line_width=2, line_color="yellow", legend="y=sqrt(x)")

show()

替代方案你也可以在散点图调用中传递“log”相关参数而不是图形(但我建议你按照我上面的说明编写它):

scatter(x, np.sqrt(x), y_axis_type="log", y_range=[0.1, 10**2], line_width=2, line_color="yellow", legend="y=sqrt(x)")

希望它有所帮助! ; - )