Tpies with Pyroot

Hello! I’m a newbie in Pyroot and I need some help with Tpies, I hope you can help me!
So, I manage to draw my Tpie using the array function to construct the Float_t *vals in:

TPie(const char *name, const char *title, Int_t npoints, Float_t *vals, Int_t *colors, const char *lbls[])

But, I can’t figure out how to do it with the labels! I really need to build an array of strings of npoints dimension, but I simply can’t. I tried with array(“c”,“blalbabla”) but that’s simply an array of chars, which doesn’t work for the case. I’ve been surfing around and the solution seems to be related to this pointers-to-Python “GetAdressOf”, but I could’t go far away.
I can input the labels manually in the graphic mode, but that’s quite annoying… I hope someone may help me!
Thanks in advance!

I finally found the solution myself, so I post it in case is useful for someone else.
Once you’ve constructed your TPie, you need to use the SetEntryLabel(a,x) method. There “a” is the label you want to change (it must be an integer) and “x” the string with the particular label.


just to confirm: I don’t know of any way of manipulating a char*[] with the current code. In all cases, there are translations of the char* to python type str (which is what one would normally want), which involve memory copies, thereby making it impossible to get the addresses right for the array.

Your solution seems to be the best.


ok, thanks Wim!