简体   繁体   English

与对数y轴的Bokeh直方图

[英]Bokeh histogram with logarithmic y axis

To create a histogram in Bokeh I can use: 要在Bokeh中创建直方图,我可以使用:

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

But the options for yscale are only 'linear', 'categorical', 'datetime' 但是yscale的选项只是'线性','分类','日期时间'

Any idea on how to create a histogram with a logarithmic yscale? 有关如何创建具有对数yscale的直方图的任何想法?

It seems that Histogram doesn't allow this, but you can try this low-level approach (based in part on an answer to similar question and this example from the docs). 似乎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")

图像生成

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM