Possible bug TGraph->InsertPoint() in v6.12.6

I think there is a bug in TGraphErrors->InsertPoint(). Earlier versions I used it to add a point to graph from mouse position, suddenly (v6.12.6) it crashes with

Error in <TGraphErrors::TGraph>: Inserted point index should be <= 0

I hope this can help somebody, if true.

Please provide the following information:

ROOT Version (e.g. 6.12/02):
Ubuntu 16.04.4 standard

I just tried with ROOT 6.13/03. I drew a graph and then inserted a point in it using the pop up menu you get with a right click on the graph. The point is inserted and I do not get any error message.

I used it in a macro that worked form v5 through v6.8, v6.10.4. I just have tested the following lines in v6.10.4, where it works and v6.12.6 where it crashes. If it is ok in 6.13. tant mieux.

TH1F *h=new TH1F("a","a",100,0,100)
double x[2]={1.,2.}
double y[2]={1.,2.}
TGraph *g=new TGraph(2,x,y)

Still could be my misunderstanding though.

In a macro you should use InsertPointBefore.
See : https://root.cern/doc/master/classTGraph.html#ad096e5f8a577bc7ad1f2b6242b45c9fc

I have fixed my macro already, I just wanted to point out the change in behavior. Since I dont know where to put a ticket, I have put it here.
BTW, InsertPointBefore needs x,y, it is not mouse input, is it?

Yes it did not make sense to call InsertPoint from a macro as it is meant to be use on screen. You just need to get InsertPoint from the menu and it insert the point at the mouse position. That’s it. From a macro you need to tell which values should be inserted and where… Then you need to use InsertPointBefore.

I did InsertPoint from the macro and it made a perfect sense. If you just wished to know, I watch the mouse events and on a middle click, I InsertPoint(). Until now, v6.12.

I have my problem solved before I posted this. The behavior change is a fact, if it is not a bug but a feature, I am ok with that.

I dont want to waste your time, since I do not have a question. If there was a ticket system (or I knew), I would be posting there to help to keep the high quality of root, one of the best SW worldwide.

I understand what you did. There is a ticket system but as you said there is nothing to report.
You should not invoke Insert point from a macro. It is not needed anymore … just go to the canvas and do insert point … .and that’s it :slight_smile:

Well, I dont want to argue, when you’re trying to help me, but me, I didnt’ say there is nothing to report. I say, that I managed to do it another way.

Concerning the invocation by a right click, you can check the effectivity of using InsertPoint() from macro https://youtu.be/8XWxYd48WY4

thank you, bye

Ok. The new InsertPoint in a context like in this video can be used too.

1 Like

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