Loading [MathJax]/extensions/tex2jax.js
Logo ROOT   6.16/01
Reference Guide
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
candleplot.C File Reference

Detailed Description

View in nbviewer Open in SWAN Example of candle plot with 2-D histograms.

void candleplot() {
TRandom *rng = new TRandom();
TDatime *dateBegin = new TDatime(2010,1,1,0,0,0);
TDatime *dateEnd = new TDatime(2011,1,1,0,0,0);
TH2I *h1 = new TH2I("h1","Machine A + B",12,dateBegin->Convert(),dateEnd->Convert(),1000,0,1000);
TH2I *h2 = new TH2I("h2","Machine B",12,dateBegin->Convert(),dateEnd->Convert(),1000,0,1000);
h1->GetXaxis()->SetTimeFormat("%m/%y");
h1->GetXaxis()->SetTitle("Date [month/year]");
float Rand;
for (int i = dateBegin->Convert(); i < dateEnd->Convert(); i+=86400*30) {
for (int j = 0; j < 1000; j++) {
Rand = rng->Gaus(500+sin(i/10000000.)*100,50); h1->Fill(i,Rand);
Rand = rng->Gaus(500+sin(i/11000000.)*100,70); h2->Fill(i,Rand);
}
}
h1->SetBarWidth(0.4);
h1->SetBarOffset(-0.25);
h1->SetFillStyle(1001);
h2->SetBarWidth(0.4);
h2->SetBarOffset(0.25);
TCanvas *c1 = new TCanvas();
h1->Draw("candle2");
h2->Draw("candle3 same");
gPad->BuildLegend(0.78,0.695,0.980,0.935,"","f");
}
@ kRed
Definition: Rtypes.h:63
@ kGreen
Definition: Rtypes.h:63
@ kYellow
Definition: Rtypes.h:63
double sin(double)
R__EXTERN TStyle * gStyle
Definition: TStyle.h:406
#define gPad
Definition: TVirtualPad.h:286
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition: TAttFill.h:37
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
Definition: TAttFill.h:39
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition: TAttLine.h:40
virtual void SetTimeDisplay(Int_t value)
Definition: TAxis.h:161
virtual void SetTimeFormat(const char *format="")
Change the format used for time plotting.
Definition: TAxis.cxx:1002
The Canvas class.
Definition: TCanvas.h:31
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
Definition: TDatime.h:37
UInt_t Convert(Bool_t toGMT=kFALSE) const
Convert fDatime from TDatime format to the standard time_t format.
Definition: TDatime.cxx:181
TAxis * GetXaxis()
Get the behaviour adopted by the object about the statoverflows. See EStatOverflows for more informat...
Definition: TH1.h:316
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
Definition: TH1.cxx:3251
virtual void SetBarWidth(Float_t width=0.5)
Definition: TH1.h:356
virtual void Draw(Option_t *option="")
Draw this histogram with options.
Definition: TH1.cxx:2974
virtual void SetBarOffset(Float_t offset=0.25)
Definition: TH1.h:355
2-D histogram with an int per channel (see TH1 documentation)}
Definition: TH2.h:211
Int_t Fill(Double_t)
Invalid Fill method.
Definition: TH2.cxx:292
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition: TNamed.cxx:164
This is the base class for the ROOT Random number generators.
Definition: TRandom.h:27
virtual Double_t Gaus(Double_t mean=0, Double_t sigma=1)
Samples a random number from the standard Normal (Gaussian) Distribution with the given mean and sigm...
Definition: TRandom.cxx:256
void SetTimeOffset(Double_t toffset)
Change the time offset for time plotting.
Definition: TStyle.cxx:1655
return c1
Definition: legend1.C:41
TH1F * h1
Definition: legend1.C:5
Author
Georg Troska

Definition in file candleplot.C.