TGraph sets nonzero points to zero


I am trying to fill a TGraph object. However, every time I try and pass a point to the TGraph, it gets set to zero or otherwise refuses to be plotted. The code:

TGraph2D* t6_11_plot = new TGraph2D();
if(e.t_drift >= 6 && e.t_drift <= 11) {
	t6_11_plot->SetPoint(eventnumber, e.x, e.y, e.t_drift);

Finally I try and write the relevant graph to a canvas for viewing with TBrowser.

TCanvas* canvas15 = new TCanvas("Drift time2", "Drift time2");
t6_11_plot->SetTitle("Drift time for 6 < t < 11");
canvas15->Write("X vs Y vs Drift time 3");

Which gives me the result

I am aboslutely certain that the relevant points are not zero. So why aren’t they plotting?

t6_11_plot->SetPoint(t6_11_plot->GetN(), e.x, e.y, e.t_drift);

1 Like

[quote=“Pepe Le Pew”]Try:
t6_11_plot->SetPoint(t6_11_plot->GetN(), e.x, e.y, e.t_drift);[/quote]

Thank so you much works fine now.