10

scatter使用 Bokeh功能时如何获得对数刻度。我正在寻找类似以下的内容:

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

或者

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

1 回答 1

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()

或者,您也可以在 scatter 调用中传递与“日志”相关的参数而不是图(但我建议您按照上面所示的方式编写它):

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)")

希望能帮助到你!;-)

于 2014-07-29T21:23:04.087 回答