00001 #include <time.h>
00002
00003 void timeonaxis()
00004 {
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 time_t script_time;
00023 script_time = time(0);
00024 script_time = 3600*(int)(script_time/3600);
00025
00026
00027
00028 gStyle->SetTimeOffset(script_time);
00029
00030 ct = new TCanvas("ct","Time on axis",10,10,700,900);
00031 ct->Divide(1,3);
00032 ct->SetFillColor(28);
00033
00034 int i;
00035
00036
00037
00038
00039 gStyle->SetTitleH(0.08);
00040 float noise;
00041 ht = new TH1F("ht","Love at first sight",3000,0.,2000.);
00042 for (i=1;i<3000;i++) {
00043 noise = gRandom->Gaus(0,120);
00044 if (i>700) {
00045 noise += 1000*sin((i-700)*6.28/30)*exp((double)(700-i)/300);
00046 }
00047 ht->SetBinContent(i,noise);
00048 }
00049 ct->cd(1);
00050 ct_1->SetFillColor(41);
00051 ct_1->SetFrameFillColor(33);
00052 ht->SetLineColor(2);
00053 ht->GetXaxis()->SetLabelSize(0.05);
00054 ht->Draw();
00055
00056
00057
00058
00059 ht->GetXaxis()->SetTimeDisplay(1);
00060
00061
00062
00063
00064 float x[100], t[100];
00065 for (i=0;i<100;i++) {
00066 x[i] = sin(i*4*3.1415926/50)*exp(-(double)i/20);
00067 t[i] = 6000+(double)i/20;
00068 }
00069 gt = new TGraph(100,t,x);
00070 gt->SetTitle("Politics");
00071 ct->cd(2);
00072 ct_2->SetFillColor(41);
00073 ct_2->SetFrameFillColor(33);
00074 gt->SetFillColor(19);
00075 gt->SetLineColor(5);
00076 gt->SetLineWidth(2);
00077 gt->Draw("AL");
00078 gt->GetXaxis()->SetLabelSize(0.05);
00079
00080 gt->GetXaxis()->SetTimeDisplay(1);
00081 gPad->Modified();
00082
00083
00084
00085
00086 float x2[10], t2[10];
00087 for (i=0;i<10;i++) {
00088 x2[i] = gRandom->Gaus(500,100)*i;
00089 t2[i] = i*365*86400;
00090 }
00091 gt2 = new TGraph(10,t2,x2);
00092 gt2->SetTitle("Number of monkeys on the moon");
00093 ct->cd(3);
00094 ct_3->SetFillColor(41);
00095 ct_3->SetFrameFillColor(33);
00096 gt2->SetFillColor(19);
00097 gt2->SetMarkerColor(4);
00098 gt2->SetMarkerStyle(29);
00099 gt2->SetMarkerSize(1.3);
00100 gt2->Draw("AP");
00101 gt2->GetXaxis()->SetLabelSize(0.05);
00102
00103 gt2->GetXaxis()->SetTimeDisplay(1);
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125 gt2->GetXaxis()->SetTimeFormat("y. %Y %F2000-01-01 00:00:00");
00126 gPad->Modified();
00127
00128 }