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

Don*_*the 5 python bokeh

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

p = Histogram(results, yscale="linear", bins=50, title = 'hist plot')
show(p)
Run Code Online (Sandbox Code Playgroud)

但 yscale 的选项只有“线性”、“分类”、“日期时间”

关于如何创建具有对数刻度的直方图有什么想法吗?

Ily*_*rov 5

似乎Histogram不允许这样做,但您可以尝试这种低级方法(部分基于对类似问题的回答和文档中的此示例)。

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")
Run Code Online (Sandbox Code Playgroud)

生成图像

  • 在 Bokeh 2.4.2 中,建议的脚本没有绘制任何内容。为了使其工作,我将“bottom=0”更改为“bottom=0.00001”。 (2认同)