Python list as source of values

Hi everyone,

I had a very basic doubt. I have a list of tuples (x,y coordinates) which is the result of a python script. Now, I want to use this list to draw a scatter plot using ROOT. The list is in the form-
[(1.0,2.3),(2.5,2.6),(3.4,3.5)]

Will greatly appreciate some help.
Thanks a lot!
Ayush

Hi,

python lists and tuples can not be sent “as is” to the C++ side: their elements need to be unwrapped first. One way of doing this that allows the argument to be sent to e.g. a TGraph, is to use Python’s class array from module array, or any of the arrays from numpy. You can also use ROOT’s array classes, such as TArrayD, but filling those will be relatively slow, as the filling loop would have to live in Python. In all cases, some copying is going to be unavoidable.

Cheers,
Wim