本文介绍了使用Bokeh的散点函数进行对数刻度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用Bokeh的scatter
函数时如何获取对数刻度.我正在寻找类似以下的内容:
How do I get log scales when using Bokeh's scatter
function. I'm looking for something like the following:
scatter(x, y, source=my_source, ylog=True)
或
scatter(x, y, source=my_source, yscale='log')
推荐答案
可以遵循以下方法进行操作:
Something along these lines will work:
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"相关的参数而不是图形(但我建议您按照上面的显示方法编写它):
Alternative you can also pass the "log"-related parameters in the scatter call instead of figure (but I recommend you to write it as I showed above):
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)")
希望有帮助! ;-)
这篇关于使用Bokeh的散点函数进行对数刻度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!