Hello everyone. I am the Laboratory Technician for Undergraduate Physics at UConn. We are looking into converting our lab notebooks from Mathematica to Python and this drawing feature helps us move away from the drawing tools in Mathematica. We are asking students to draw predictions of position, velocity, and acceleration plots of a cart accelerating down a ramp. We want to use this freehand draw tool inside of our Goolge Colab notebook. We are able to get the code to generate the drawing environment however, it is a bit difficult for our introductory students to call and upload the saved png from their Drive folders (we don’t want to ask the students to mount the Google Drive everytime). What we want to do is have the students be able to save the drawings they made to the output file so that when their TA opens the file after not having run the cells, can still view the students answer.
tl;dr
Is there a way to save the drawing created on the output of the FreehandDrawingTool directly inside the output html file so that it can be seen when the file is reopened by someone else? I do not want to use the export png feature, since it gets too complicated for students to mount the Google Drive and load the file.
The current code looks like this:
from bokeh.io import output_notebook
from bokeh.plotting import figure, output_file, show, save
from bokeh.models import FreehandDrawTool
output_file("x(t).html")
output_notebook()
p = figure(x_range=(0, 1), y_range=(0, 1), width=400, height=400,
title='x(t) vs t')
p.xaxis.axis_label = "t"
p.yaxis.axis_label = "x(t)"
renderer = p.multi_line([[0, 0]], [[0, 0]], line_width=5, alpha=1, color='red')
draw_tool = FreehandDrawTool(renderers=[renderer], num_objects=1)
p.add_tools(draw_tool)
p.toolbar.active_drag = draw_tool
show(p)