updating bokeh plot with a bokeh widget in jupyter notebook
Date : March 29 2020, 07:55 AM
To fix this issue I got the plot to update as expected by displaying the figure and the slider widget within a bokeh.layouts.row layout: from bokeh.plotting import figure
from bokeh.io import output_notebook, push_notebook, show
from bokeh.models import CustomJS, Slider
from bokeh.layouts import row
output_notebook()
power = 0.5
x = [1,2,3]
y = [i**power for i in x]
fig = figure()
plt = fig.circle(x, y)
def update_plot(power):
x = plt.data_source.data['x']
plt.data_source.data['y'] = [i**power for i in x]
push_notebook(handle=bokeh_handle)
##### new notebook cell #####
callback = CustomJS(code="""
if (IPython.notebook.kernel !== undefined) {
var kernel = IPython.notebook.kernel;
cmd = "update_plot(" + cb_obj.value + ")";
kernel.execute(cmd, {}, {});
}
""")
slider = Slider(start=0.1,
end=1,
value=1,
step=.05,
title="power",
callback=callback)
bokeh_handle = show(row(fig, slider), notebook_handle=True)
|
bokeh not showing in jupyter notebook
Date : March 29 2020, 07:55 AM
hop of those help? My guess is that your version of the notebook is too old. There is no technical path to simultaneously supporting both the new JupyterLab and classic notebook versions older than 5.0, at all. Supporting JupyterLab is an imperative, so as of recently, Bokeh can only support classic notebook 5.0 and newer. So, you can: downgrade Bokeh (<= 10.12.8), or updgrade Jupyter Notebook (>= 5.0), or jupyter labextension install jupyterlab_bokeh
|
Jupyter and Bokeh: workaround for exporting bokeh plots when exporting Jupyter notebook to pdf
Tag : python , By : jumpingmattflash
Date : March 29 2020, 07:55 AM
Hope that helps Standard interactive Bokeh plots are actually collections of JSON, together with a JavaScript library (BokehJS) that renders the JSON as the desired plot in a browser. Since PDF documents do not execute JavaScript, it will never be possible to embed standard Bokeh plots in PDF form. However, Bokeh can also export static versions of plots as PNG or SVG, which can be embedded in PDFs. See the section Exporting Plots in the User's guide. You will first need to install some optional dependencies (phantomJS, selenium and pillow) and then to export the plot will be something like this: export_png(plot, filename="plot.png")
from IPython.display import Image
Image('plot.png')
|
How to generate static Bokeh plots in jupyter notebook?
Date : March 29 2020, 07:55 AM
around this issue In Bokeh 0.12.15 there is an internal function which can do the heavy lifting here. Note that the function is undocumented, so it's probably not meant to be used externally. After installing the additional export requirements of pillow, selenium and phantomjs, you can run the following to get a static plot:
|
bokeh.charts is gone - what library can do interactive, colored scatterplots?
Tag : python , By : Jakub Filak
Date : March 29 2020, 07:55 AM
I wish did fix the issue. One of the visualizations I find myself doing most often is the following: I have x,y Data, labeled in categories. I need to plot this in a scatterplot, automatically coloring the dots according to the label, and generating a legend. The visualization should then be interactive (zoomable, hovering over points shows Metadata, etc...) , This is pretty trivial to achieve in modern versions of Bokeh: from bokeh.plotting import figure, show
from bokeh.sampledata.iris import flowers as df
from bokeh.transform import factor_cmap
SPECIES = ['setosa', 'versicolor', 'virginica']
p = figure(tooltips="species: @species")
p.scatter("petal_length", "sepal_width", source=df, legend="species", alpha=0.5,
size=12, color=factor_cmap('species', 'Category10_3', SPECIES))
show(p)
|