TGraph::SetPoint() and graph's histogram settings

Hi,
I’m writing a kind of slow control system. For two dimensional plots I
use TGraph and my program calls TGraph::SetPoint when it gets new
events. It works almost fine but I’m looking for a way to get rid of a
problem. Firstly, I noticed that
graph->GetXaxis()->SetTimeDisplay(kTRUE) has no effect due to
TGraph::SetPoint() removes graph’s histogram. Secondly, axis zoom
is discarded with a new event because of the same reason.

A short script to reproduce this behavior:

[code]{
gr_date = new TGraph();
gr_date->SetPoint(0, time(0), 1);
gr_date->GetXaxis()->SetTimeDisplay(kTRUE);
c_date = new TCanvas(“c_date”, “c_date”);
gr_date->Draw(“ap”);

gr_nodate = new TGraph();
gr_nodate->GetXaxis()->SetTimeDisplay(kTRUE);
gr_nodate->SetPoint(0, time(0), 2);
c_nodate = new TCanvas(“c_nodate”, “c_nodate”);
gr_nodate->Draw(“ap”);
}[/code]

Is there a more convenient class for my purpose?

Max

I suggest to use a TMultiGraph as shown below

Rene

{
c_date = new TCanvas(“c_date”, “c_date”);
multi = new TMultiGraph();

gr2 = new TGraph();
gr2->SetPoint(0, time(0), 2);
multi->Add(gr2,“p”);
multi->Draw(“a”);
multi->GetXaxis()->SetTimeDisplay(kTRUE);
gr2->SetPoint(1, time(0)+2, 3);
gr2->SetPoint(2, time(0)+3, 4);
gr2->SetPoint(3, time(0)+4, 5);
c_date->Modified();
}

Hi Rene,
Thank you for the suggestion.

However it seems that saving and restoring time format is easer than
using the TMultiGraph class although my work-around doesn’t solve the
zoom issue. I see at least two difficulties with TMultiGraph. I can’t
prepare several graphs for delayed drawing, I have to paint their to get
valid pointers to the x axes. Updating (extending) x and y axis ranges
also become my task.

Max