具有对数 y 轴的散景直方图

Bokeh histogram with logarithmic y axis

要在 Bokeh 中创建直方图,我可以使用:

p = Histogram(results, yscale="linear", bins=50, title = 'hist plot')
show(p)

但是yscale的选项只有'linear'、'categorical'、'datetime'

知道如何使用对数 yscale 创建直方图吗?

似乎 Histogram 不允许这样做,但您可以尝试这种低级方法(部分基于文档中的 answer to similar question and this example)。

import numpy as np
from bokeh.plotting import figure, show
from bokeh.sampledata.autompg import autompg as df

p = figure(tools="pan,wheel_zoom,box_zoom,reset,previewsave",
       y_axis_type="log", y_range=[10**(-4), 10**0], title="log histogram")

hist, edges = np.histogram(df['mpg'], density=True, bins=50)
p.quad(top=hist, bottom=0, left=edges[:-1], right=edges[1:],
       fill_color="#036564", line_color="#033649")