I’ve written a small proof-of-concept macro to make a time history plot of two different recorded variables. I’ve the timestamps of each measurement and the actual measurements for each variable in arrays that I declared within the macro. The actual data is going to come from a database query with a certain timestamp field. I was wondering if/how I would be able to display these graphs without first converting the timestamp into seconds from a certain year/date/time.
If converting it to seconds is the only way to do it, then that’s okay too, but then I have a question about the time axis. Right now it starts from some date in 1994, but once or twice it started from 2006 (arbitrarily, I don’t believe I changed anything of importance). What can I do to start the time axis from a very specific date and time?
My macro is attached. Run it with:
root [0] .L timegraphL.C
root [1] twoscales()
Thank you very much,
Mikhail timegraphL.C (2.28 KB)
timeonaxis4 ()
{
TGraph *graph = new TGraph;
gStyle->SetTimeOffset(0);
// Point 1 given by : date -d "01/01/1985" +%s
graph->SetPoint(0, 473382000.0 ,1.0);
// Point 2 given by : date -d "07/02/1985" +%s
graph->SetPoint(1, 489103200.0 ,2.0);
// Point 3 given by : date -d "01/01/1986" +%s
graph->SetPoint(2, 504918000.0 ,3.0);
graph->Draw("AL*");
TH1F *hist = graph->GetHistogram();
TAxis *axis = hist->GetXaxis();
axis->SetTimeDisplay(1);
axis->SetTimeFormat("%Y-%m-%d");
axis->SetNdivisions(204,false);
}