holoviz-topics / EarthSim

Tools for working with and visualizing environmental simulations.
https://earthsim.holoviz.org
BSD 3-Clause "New" or "Revised" License
65 stars 21 forks source link

Save drawing to png #163

Closed kcpevey closed 3 years ago

kcpevey commented 6 years ago

I dug around on the interwebs and found some discussion on why this is challenging (admittedly didn't understand half of it). What I came up with was this command:

%%output fig='png' filename='foo'

If I'm using the drawing tools, that will grab the tables too. Is there another/better way to grab JUST the Drawing (preferably without the tool icons)?

jbednar commented 6 years ago

If you have a handle to the object you want to plot (e.g. the polygons overlaid on a map, or whatever specific thing you want), you should be able to use the instructions in http://holoviews.org/user_guide/Plots_and_Renderers.html to render it to PNG. E.g.:

import holoviews as hv
hv.extension("bokeh")

curve = hv.Curve(range(10))
renderer=hv.renderer('bokeh')
renderer.save(curve.options(toolbar=None), '/tmp/test', fmt='png')
!open /tmp/test.png

In this case, you might have to do some work to get the specific object you want, possibly recreating just the bits you need in a subsequent cell.

kcpevey commented 5 years ago

Assigning this to myself to test Jim's suggestion

jbednar commented 5 years ago

I think there's actually a simpler way now. @jlstevens?

jlstevens commented 5 years ago

There is now hv.save which takes the object to export and some arguments. It has a decent docstring which explains how to use it...