Newbie oddities

I’m trying to plot some data with errorbars, the data is imported as a numpy array with data[:,0] = measurement, data[:,1] = errors. I can plot the data fine with gnuplot and ROOT.TF1 (don’t ask!), but the following just shows an empty canvas…

can = TCanvas("can","A somp")
g = TGraphErrors()
g.SetTitle("Helo")
g.Draw()
for y,ey in muplus:
   n = g.GetN()
   g.SetPoint(n, n, y)
   g.SetPointError(n, 0, ey)
g.Draw()

Any hints?

Another question, if I want to define another range on the x axis, I could use SetRangeUser right? instead of the data line number I want the rapidity in the interval from -2 to 2, but that doesn’t seem to work either :frowning:

g.SetUserRange(-2.0,2.0)

I have attached my work file as well.

Any help will be greatly appreciated!

Morten
article1.py (2.08 KB)

{
   TGraph *gr = new TGraph(3);
   gr->SetPoint(0,1,2);
   gr->SetPoint(1,0,2);
   gr->SetPoint(2,1,0);
   gr->GetXaxis()->SetLimits(-2.,2.);
   gr->GetHistogram()->SetMaximum(3.);
   gr->GetHistogram()->SetMinimum(-3.);
   gr->Draw("AL*");
}