Thanks @Bryan …it works perfectly…but I have a new problem with it if I add a button for downloading the screenshot…it is showing an error…I can post the minimal example and not the
full code…The warning is:-( The webdriver raised a TimeoutException while waiting for a ‘bokeh:idle’ event to signify that the layout has rendered. Something may have gone wrong. ).
Please help me out with this. Thanks in advance
minimal code:
import numpy as np
import pandas as pd
from bokeh.io import show, output_file
from bokeh.io import curdoc
from bokeh.models import ColumnDataSource, Select
from bokeh.plotting import figure
from bokeh.layouts import layout, widgetbox, column, row, gridplot
from bokeh.models import HoverTool,LassoSelectTool,WheelZoomTool,BoxZoomTool,ResetTool,PanTool
from bokeh.palettes import GnBu3, OrRd3
from bokeh.plotting import reset_output
from bokeh.io import export_png
from bokeh.models.widgets import Button
source = ColumnDataSource({‘x’: , ‘y’: })
i=1.0
X=
def update():
global i
x=[2,3,4]
global X
X=[i*n for n in x]
print(X)
i=i/1.1
source.data.update(x=X, y=[0.5, 1.5, 2.5])
curdoc().add_periodic_callback(update,10000)
fig= figure(plot_width=1000,plot_height=300,x_axis_label=‘k’,title='Power ',toolbar_location=“above”,tools=“”)
fig.hbar(y=‘y’, right=‘x’,height=0.4,color=OrRd3[1],source=source)
button = Button(label=“Download”)
def download():
export_png(doc_layout, filename="fig.png")
controls = [button]
controls[0].on_click(download)
doc_layout= layout([[widgetbox(button)],[fig]],sizing_mode=‘fixed’)
curdoc().add_root(doc_layout)
curdoc().title = “Live updating”
···
On Thursday, December 14, 2017 at 12:50:15 AM UTC+5:30, Bryan Van de ven wrote:
Hi,
Two observations:
First, your code correctly produces a fig1.png for me. So my guess is that the server wherever you are running this has an incompatible version of phantoms or possibly node.
Second, the fig1.png is of an empty (blank) plot. The export_png function is only called once, before any data, so an empty plot is completely expected, given the code as it is. I’m not sure if your code is simplified for demonstration but I wanted to point it out.
Thanks,
Bryan
On Dec 13, 2017, at 01:39, [email protected] wrote:
Hello everyone…I installed PhantomJS and tried exporting png of the bokeh layout through IPython(Jupyter)…It’s working beautifully…But I have a problem doing it in Bokeh Server…here is the minimal example of it:-
import numpy as np
import pandas as pd
from bokeh.io import show, output_file
from bokeh.io import curdoc
from bokeh.models import ColumnDataSource, Select
from bokeh.plotting import figure
from bokeh.layouts import layout, widgetbox, column, row, gridplot
from bokeh.models import HoverTool,LassoSelectTool,WheelZoomTool,BoxZoomTool,ResetTool,PanTool
from bokeh.palettes import GnBu3, OrRd3
from bokeh.plotting import reset_output
from bokeh.io import export_png
source = ColumnDataSource({‘x’: , ‘y’: })
i=1.0
X=
def update():
global i
x=[2,3,4]
global X
X=[i*n for n in x]
print(X)
i=i/1.1
source.data.update(x=X, y=[0.5, 1.5, 2.5])
curdoc().add_periodic_callback(update,10000)
fig= figure(plot_width=1000,plot_height=300,x_axis_label=‘k’,title='Power ',toolbar_location=“above”,tools=“”)
fig.hbar(y=‘y’, right=‘x’,height=0.4,color=OrRd3[1],source=source)
export_png(fig, filename=“fig1.png”)
curdoc().add_root(fig)
curdoc().title = “Live updating”
Please help me out as it is giving an error like this
–
You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/04bc575e-d78b-4519-87fd-0ad67cef94a9%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.