Dumping plot in py

Hello everyone

First i’d like to thank you guys for the amazing job done with python in 6.22 : out of the box we have both python 2 & 3 working smoothly with a single installation, numpy arrays are there without problem, ctypes are now the default, and from some very preliminary test, it seems to wokr as well on Windows 10… A lot of things have been done and that’s great.

I’ve been receiving questions from python users wondering whethe you have considered dumping plots in python (as you’re doing in C++). They are newcomers, python fan boy and they use ROOT in interactive to create their plot and would like to have the command in python that correspond to what they’ve done.

Any idea whether this exits ? Is this in the pipe ? do you recommand to dump in C++ to get the general idea ?

Thanks anyway for the great work.
jb


Please read tips for efficient and successful posting and posting code

_ROOT Version: 6.22.02
_Platform: Fed 32
_Compiler: gcc10


Dear @jbb ,

Thank you for your message, much appreciated!

When you say dumping a plot, you mean generating the code that can produce that plot, right?

Unfortunately I am not aware of this existing for Python, only C++, @couet can confirm, and there are no plans to implement it. But codewise, there shouldn’t be much difference between the generated C++ code and its equivalent in Python, since it should basically consist in calls to the graphics API of ROOT.

The only thing that should be taken into account when translating is that, in Python, when creating a canvas or any object that is added to a canvas, such objects need to be alive for you to see them in the plot. In other words, if you create an object (e.g. a TText) inside a function, add it to the canvas and then return from the function, that object will not appear anymore in the canvas (since it was garbage collected by Python).

Thanks a lot

That is the answer i gave to the users, but some are afraid to look at C++ :crazy_face:

They’ll come back to me if they face problem.

thanks anyway
cheers
jb

Yes, a canvas can be saved as “code” only in C++.

wouldn’t saving the canvas/pad in json somewhat address your issue?
(then python users could devise a little python script to do what they please)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.