In the example, where do I insert the data?

Hi, I’m traying to do a histogram, using, but cant find or dont know where to insert my data.csv to see results. I dont eaven know from where is the data of that example comming from. can any one please help me on this?

here’s the link to — Bokeh 2.4.3 Documentation

Hi @jsgaston,

If you look at the code they generate a histrogram with np.histogram, then pass that to the quad functions (see Quad). In the documentation they use a ColumnDataSource, but in they effectively do,

import numpy as np
from bokeh.plotting import figure, curdoc

mu, sigma = 0, 0.5

# Here is the data
measured = np.random.normal(mu, sigma, 1000)
hist, edges = np.histogram(measured, density=True, bins=50)

p = figure(title=title, tools='', background_fill_color="#fafafa")
p.quad(top=hist, bottom=0, left=edges[:-1], right=edges[1:],
            fill_color="navy", line_color="white", alpha=0.5)


then run bokeh serve

Hope this helps!

1 Like

measured is the data?

Yes, if you use ipython and look at the output it is just a normal distribution np.random.normal.

$ ipython
Python 3.9.2 (default, Feb 28 2021, 17:03:44) 
Type 'copyright', 'credits' or 'license' for more information
IPython 8.3.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import numpy as np

In [2]: mu, sigma = 0, 0.5

In [3]: np.random.normal(mu, sigma, 1000)
array([-2.65413158e-01, -6.27418248e-02,  6.94722716e-01,  6.69866563e-01,
       -6.66212401e-01, -7.08121404e-01,  6.18151911e-02, -5.52265635e-01,
       -9.64723514e-01,  2.24599970e-02, -7.16623197e-01, -1.50668735e-01,
       -3.04206225e-01,  2.41371779e-01, -6.36075849e-01,  1.20183754e-01,
       -8.21533018e-01,  2.21056970e-01,  2.06465002e-01,  8.02502840e-01,

Or you could run the above in a notebook to check.

np.histogram puts it into a format that is compatible for p.quad (or traditionally matplotlib.pyplot.hist).

1 Like