Hi Gagik,
If I understand you correctly you would like to plot something like
a time series. Here is a simple macro that can accomplish this.
I am using a class "TSDate" to calculate business dates, replace it
with your own times:
{
TCanvas *c1 = new TCanvas("c1","A Simple Graph",200,10,700,500);
c1->SetGridx();
c1->SetGridy();
Float_t x[20],y[20];
Char_t *daystr[20];
TSDate day;
//-- make data
Int_t n = 20;
TSDate sday("1/1/99");
Long_t sbusday = sday.GetDateNr();
for (Int_t i=0;i<n;i++)
{
day.SetDate(sbusday+i);
x[i] = day.GetDateNr();
y[i] = TMath::Sin((x[i]-sbusday)/n*2*TMath::Pi());
}
//--- code needed to get date strings for the x labels
Int_t nrDivisions = 5;
Float_t xmin = x[0]-1.0;
Float_t xmax = x[n-1]+1.0;
Float_t ymin = -1.5;
Float_t ymax = 1.5;
TH1F *frame = new TH1F("frame","bla bla",2,xmin,xmax);
{
frame->SetMinimum(ymin);
frame->SetMaximum(ymax);
frame->SetLabelOffset(10);
frame->SetLabelSize(0.0);
frame->SetNdivisions(-nrDivisions);
frame->SetTitleOffset(1.1,"X");
frame->SetXTitle("time");
frame->SetTitleOffset(1.1,"Y");
frame->SetYTitle("who knows");
frame->Draw();
}
TText *t = new TText();
{
t->SetTextAlign(22);
t->SetTextSize(0.030);
}
Float_t timeSpan = xmax-xmin;
Float_t step = Float_t(timeSpan/nrDivisions);
Float_t dist = TMath::Abs(ymax-ymin);
for (Int_t j=0; j<nrDivisions+1;j++)
{
Float_t xpos = xmin+j*step;
Float_t ypos = ymin-0.05*dist;
day.SetDate(xpos);
t->DrawText(xpos,ypos,day.GetDateString());
}
//-- Finally plot the graph
gr = new TGraph(n,x,y);
gr->SetMarkerStyle(20);
gr->SetMarkerSize(1.0);
gr->SetMarkerColor(kRed);
gr->SetLineWidth(1.0);
gr->Draw("LP");
}
Eddy
Renaissance Technologies Corp.
This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:25 MET