This macro illustrates the use of the time axis on a TGraph with data read from a text file containing the SWAN usage statistics during July 2017.
7 dirName = str(ROOT.gROOT.GetTutorialDir())
9 dirName= dirName.replace(
"/./",
"/")
10 inputFileName =
"%s/SWAN2017.dat" %dirName
14 g.SetTitle(
"SWAN Users during July 2017;Time;Number of Sessions")
19 lines =
open(inputFileName,
"r").readlines()
21 for i, line
in enumerate(lines):
22 d, h, value = line.split()
23 g.SetPoint(i, ROOT.TDatime(
"%s %s" %(d,h)).Convert(), float(value))
26 c = ROOT.TCanvas(
"c",
"c", 950, 500)
28 c.SetRightMargin(0.04)
31 g.SetLineColor(ROOT.kBlue)
33 g.GetYaxis().CenterTitle()
37 xaxis.SetTimeDisplay(1)
39 xaxis.SetTimeFormat(
"%a %d")
40 xaxis.SetTimeOffset(0)
41 xaxis.SetNdivisions(-219)
42 xaxis.SetLimits(ROOT.TDatime(2017, 7, 3, 0, 0, 0).Convert(), ROOT.TDatime(2017, 7, 22, 0, 0, 0).Convert())
43 xaxis.SetLabelSize(0.025)
- Authors
- Danilo Piparo, Olivier Couet
Definition in file timeSeriesFromCSV.py.