#include "TString.h" #include "TDatime.h" #include "TGraph.h" #include "TAxis.h" #include "TCanvas.h" void test(const char *fin = "file.txt") { if (!fin && !fin[0]) return; // just a precaution std::ifstream ifs(fin, std::ifstream::in); if (!ifs.good()) return; // just a precaution TString ymd, hms; Double_t v,x,z,y; TGraph *g = new TGraph(); // TH1F* h1 = new TH1F("h1","test",100,X1,X2); while(ifs >> ymd >> hms >> v >> x >> z >> y) { TDatime t(ymd + " " + hms); // "yyyy-mm-dd hh:mm:ss" g->SetPoint(g->GetN(), t.Convert(), z); } //int nPoints = g->GetN(); if (g->GetN() > 1) { g->GetXaxis()->SetTimeDisplay(1); g->GetXaxis()->SetTimeFormat("#splitline{%y-%m-%d}{%H:%M:%S}%F1970-01-01 00:00:00"); g->GetXaxis()->SetLabelOffset(0.025); TCanvas *c = new TCanvas("c", "c",99,208,1789,704); c->Range(1.501311e+09,84,1.502605e+09,258); c->SetFillColor(0); c->SetBorderMode(0); c->SetBorderSize(2); c->SetFrameBorderMode(0); c->SetFrameBorderMode(0); g->GetXaxis()->SetTitle("[year-month-date ; hour-min-sec]"); g->GetXaxis()->SetTickLength(0.2); g->GetXaxis()->SetLabelFont(42); g->GetXaxis()->SetLabelOffset(0.025); g->GetXaxis()->SetLabelSize(0.03); g->GetXaxis()->SetTitleOffset(1.45); g->GetXaxis()->SetTitleFont(42); g->GetYaxis()->SetTitle("#frequency"); g->GetYaxis()->SetLabelFont(42); g->GetYaxis()->SetTitleFont(42); g->Draw("ALP"); g->SetLineWidth(3); c->Modified(); c->Update(); } }