When the cells are executed locally, a TCanvas shows up and the plot is shown but then it disappears immediately when ROOT exits. On the nbviewer it would only show printed text output, not windows.
But I am wondering if there is a way to make the %%script root magic work in such a way that the windows are captured? Is it way too hard to do, or is there some clever way to make it work?
For running notebooks locally, is there a way to make the %%script root session not exit immediately?
You can a course save plots to a file supported by notebooks (e.g. PNG) and then display that in the notebook with e.g. IPython.display.display(IPython.display.Image(png_file)).
To be honest I don’t really see the point of using script magic when everything you need should be available from PyRoot (file a bug if something is missing), or you can use ROOT.ProcessLine to e.g. include “magic” headers like cmath.
rootpy now automatically detects if you are running in an IPython notebook and displays canvases, histograms, and functions as inline images instead of in a separate window.
I also just started using IPython notebooks. Very cool product. I love being able to connect to my remote notebook server to interactively plot my large datasets.
Anyone willing to create a JavaScript widget to replace ROOT’s GUI so we can have interactive ROOT plots embedded in notebooks? That would be revolutionary! Imagine rotating/scaling plots in a notebook on your phone
Also see rootpy’s wait() function in rootpy.interactive.
from rootpy.plotting import Canvas
from rootpy.interactive import wait
c = Canvas()
wait() # wait for user to close all canvases before moving on
This prevents the interpreter from exiting (for example) while (non-batch) canvases are open.