Save Drawing from FreehandDraw Tool with Colab

Hello everyone,

Please take a look at this Google Colab file:

The HoloView code is as follows:

import holoviews as hv
from holoviews import opts
from holoviews import streams
%env HV_DOC_HTML=true
path = hv.Path([])
freehand = hv.streams.FreehandDraw(source=path, num_objects=3)

    opts.Path(active_tools=['freehand_draw'], height=400, line_width=10, width=400)), 'fig1.png', backend='matplotlib')

I am attempting to sketch a prediction of a curve onto an empty x-y coordinate system and save the resulting figure as a png to be called back for later use. However, I do not want to use the “Save” tool, since this sends a download of the png to the “Downloads” folder on my computer.

In the Colab file provided, when is run, the image that gets saved is the figure but before I have drawn anything on it.

In other words, the line that I am drawing on the output is not saving to the png.

Any help would be great.


Two things, Colab is a non open source fork of Jupyter which does not follow any of the standard Comm APIs, which means we have no way of making many of the interactive features in our projects work. There is no mechanism by which we can communicate changes on the frontend (e.g. freehand draw events) back to Python. So unless Colab follows standard APIs or provides some clear mechanism to do this kind of thing there is no way this can work on Colab.

Secondly the FreehandDraw stream and other streams do not edit objects in place, instead they return a new element. So if you want to save the drawn output you will want to do this:, 'fig1.png', backend='matplotlib')