I am new to Bookeh and I have a task to plot the spectrogram in bokeh.
I am using https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.spectrogram.html to get the spectrogram. In the above example they are using pcolormesh() of matplotlib to plot the spectrogram. How can I get the same(or equivalent) spectrogram plot in bokeh.
I have tried to get it done by plotting a heatmap by using the folowing code:
f, t, Sxx = spectrogram(raw_data, fs)
i=0
for freq in range(f.shape[0]):
for time in range(t.shape[0]):
df_spectogram.loc[i] = [f[freq],t[time],Sxx[freq][time]]
i = i+1
TOOLS = "hover,save,pan,box_zoom,reset,wheel_zoom"
PALETTE = ['#081d58', '#253494', '#225ea8', '#1d91c0', '#41b6c4', '#7fcdbb', '#c7e9b4', '#edf8b1', '#ffffd9']
mapper = LinearColorMapper(palette=PALETTE, low=numpy.min(Sxx), high=numpy.max(Sxx))
spectogram_figure = figure(title="Spectogram",x_axis_location="below", plot_width=900, plot_height=400,
tools=TOOLS)
spectogram_figure.background_fill_color = "#eaeaea"
spectrogram_source = ColumnDataSource(data=dict(Sxx=df_spectogram['Sxx'],Frequency=df_spectogram['Frequency'],Time=df_spectogram['Time']))
spectogram_figure.circle(x="Time", y="Frequency", source=spectrogram_source, fill_color={'field': 'Sxx', 'transform': mapper}, line_color=None)