Limit contour curve

I have a text file where on each line there are the values x and y (data.txt).
All the (x,y) points correspond to a limit exclusion curve.
I would like to plot it. I should get something like in the the attachement (example_limit.pdf),
obtained in a completely different way.
I tried with TGraph, TPolyLine but when I draw with the option L I get something bad.
I think I need a sort function that finds the closes points but I didn’t find.
Is there any other way to do that?

Thanks for help!
example_limit.pdf (19.1 KB)
data.txt (233 KB)

Can we see the “bad thing” you get ?

I drew with the options AL
example_limit_2.pdf (53.3 KB)

Hello, your problem comes from the fact that you use “L” option since you data are not sorted
This is what I get with this macro


TGraph *g = new TGraph(“data.txt”);
Anyway, even if you sort your points, you will still have this line between the two “circles” (on the right on your figure). To avoid it, you can use “AP” option, as I did or define two different TGraphs.

The thing is I would like to get two continuos curves without any break. So I tried with L option.
I think that also doing Draw(“AL”) with two different TGraph I get the filled black area, even if
I didn’t give any kind of option to do that (I put a zoom of my plot).

example_limit_Zoom.pdf (12.7 KB)

You should use AL, but you need:

  1. to order the points,
  2. to make a graph for each contour. You can group them in a TMultiGraph.

It is not a filled polygon but you have so many lines going from one side of the contour to the other that they fill the contour.

Ok, fine.
About the filled area it should be because
by default it sorts along the x axis.

Thank you very much.

no, TGraph does not sort the points it takes them in the order you put them in the file. In that file one point is on one side of the contour and the next one on the other side. That’s why you get this filling effect.

Ok. Thanks!