AttributeError: 'TObject' object has no attribute 'SetLineColor'

Dear experts,

I have a script in python that uses ROOT and I am getting a following error:

AttributeError: ‘TObject’ object has no attribute ‘SetLineColor’

for this line: gr.SetLineColor(ROOT.kViolet) .

Could you please tell me what could be wrong here? I suppose there are some problems with the python or ROOT versions that I use?

I use Python 2.7.14+ and ROOT 6.12/07.

I hope that with this information it is possible to find out what’s wrong.

Thank you!


You are trying to set the line color of a TObject. TObject does not inherit from Tattling there it does not have the SetLineColor method. You should tell use a bit more. Show your code so we can see what gr should be (very likely a TGraph I guess).

Dear @couet ,

Yes, it is a TGraph. I think I found the problem. It was trying to access a TGraph from a file, which did not exist, and for some reason it gave the AttributeError instead of saying that the graph that I am trying to access does not exist. Weird, but at least the issue seems to be found.

Thank you for your time!

1 Like