producing png files without clicking on preview/save

Hi,
I have been using Bokeh to make large categorical maps and find it very useful. Since there is no zoom-in option available for categorical maps, I am using a modified version of scatter plot that looks like a categorical plot with zoom-in option. Because of all this and my large data set, I end up with html files that are relatively large (~20 GB). At this point I don’t mind having such large files, but I want to put those information at various sites for my colleagues to see. The easier think that I thought was to make png file and place them in various sites that I want, but give a link to the original interactive html pages. Since I want to automate this process, is there a way to produce png files from command line while making those html files. Currently the only options available is to produce png files via clicking preview/save button, which isn’t good for automation.
Thanks
shivaraj

Hi shivaraj,

Unfortunately there is currently no good way to export images programmatically from Bokeh. This is a feature that would be extremely welcome, but there are surprising technical challenges to getting data from a browser saved to disk without user intervention. One possibility for the future is "MEP25" which would allow us to export static Bokeh plots to Matplotlib, where all of matplotlib's extensive image export machinery can be leveraged. But I don not know what a timeline for MPL to implement MEP25 is. Another possibility is to create a service that would allow for sending image data to some cloud service for saving, since the browser cannot save to local disk easily. If you have any input or suggestions of things we may not have thought of, any assistance is welcome.

Bryan

···

On Dec 4, 2014, at 3:26 PM, shivaraj kandhasamy <[email protected]> wrote:

Hi,
  I have been using Bokeh to make large categorical maps and find it very useful. Since there is no zoom-in option available for categorical maps, I am using a modified version of scatter plot that looks like a categorical plot with zoom-in option. Because of all this and my large data set, I end up with html files that are relatively large (~20 GB). At this point I don't mind having such large files, but I want to put those information at various sites for my colleagues to see. The easier think that I thought was to make png file and place them in various sites that I want, but give a link to the original interactive html pages. Since I want to automate this process, is there a way to produce png files from command line while making those html files. Currently the only options available is to produce png files via clicking preview/save button, which isn't good for automation.
Thanks
shivaraj

--
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/061ccb8b-86db-452c-9f7f-c9be87565d4b%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hi Bryan,
Thanks for info. I found a solution (a fix) to produce png files. The “phantomjs” a javascript API covnerts html to png files. So I basically used it at the end of the bokeh code to produce png files. It is not bad. Below is an example of line.py with phantomjs code added (one line). phantomjs and rasterize.js comes with PhantomJS package download.

import numpy as np
import os
from bokeh.plotting import *
from bokeh.objects import PanTool
N = 80

x = np.linspace(0, 4*np.pi, N)
y = np.sin(x)

output_file(“line.html”, title=“line.py example”)

pantool = PanTool(dimensions=[“width”, “height”])
line(x,y, color="#0000FF", tools=[‘wheel_zoom’,‘box_zoom’, pantool],
name=“line_example”)

os.system("./phantomjs rasterize.js line.html line.png")

Hi shivaraj,

Thanks for the info! We eventually achieve a stronger solution to this request. There are already some discussion happening to support this and other kind of exportations.

Cheers.

Damian

···

On Thursday, December 11, 2014 3:42:10 PM UTC-3, shivaraj kandhasamy wrote:

Hi Bryan,
Thanks for info. I found a solution (a fix) to produce png files. The “phantomjs” a javascript API covnerts html to png files. So I basically used it at the end of the bokeh code to produce png files. It is not bad. Below is an example of line.py with phantomjs code added (one line). phantomjs and rasterize.js comes with PhantomJS package download.

import numpy as np
import os
from bokeh.plotting import *
from bokeh.objects import PanTool
N = 80

x = np.linspace(0, 4*np.pi, N)
y = np.sin(x)

output_file(“line.html”, title=“line.py example”)

pantool = PanTool(dimensions=[“width”, “height”])
line(x,y, color="#0000FF", tools=[‘wheel_zoom’,‘box_zoom’, pantool],
name=“line_example”)

os.system("./phantomjs rasterize.js line.html line.png")