I am using ipython and ipython notebook with rootnotes.py.
I have set the Xs, so I can see my plots in the Xs, and I am also saving them in png format.
Png saved files are fine, and also visible from ipython notebook running the commands:
from IPython.core.display import Image
However, the plots vanish from the Xs after few seconds and just the axis and the title axis remain (no data points, neither legends nor plot title).
[quote=“arodrig”]the canvas is indeed within a function body, but I am returning that canvas (return canvas).[/quote]but where is it subsequently going? I.e. what is holding a reference to it?
[quote]Is there any way to avoid the freing of that object?[/quote]Yes, using ROOT.SetOwnership(canvas, False). But make sure that someone deletes it at all, or the canvases will stay around until shutdown (at which point they’ll be cleaned up by the TROOT destructor).
sorry, I can’t make sense of that: if the ownership is not on the python side, definitely python is not removing the canvas. Likewise, it is still not clear to me what would hold a return value from that function.
Maybe I’m misreading your initial post and it is not the canvas that disappears, but the data points? I.e. what is called “dataG” in the original code and to which the “plot” dictionary holds a reference whereas in your case it is removed as it is not returned after your change.