5

To create a histogram in Bokeh I can use:

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

But the options for yscale are only 'linear', 'categorical', 'datetime'

Any idea on how to create a histogram with a logarithmic yscale?

Don Smythe
  • 9,234
  • 14
  • 62
  • 105

1 Answers1

5

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

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

image generated

Community
  • 1
  • 1
Ilya V. Schurov
  • 7,687
  • 2
  • 40
  • 78
  • 2
    In Bokeh 2.4.2, nothing was plotting with the suggested script. To make it work, I changed "bottom=0" by "bottom=0.00001". – Marmoz Dec 15 '21 at 14:43