ROOT
master
Reference Guide
Loading...
Searching...
No Matches
hist049_Graphics_candle_plot.C File Reference
Tutorials
»
Histograms tutorials
Detailed Description
Example of candle plot with 2-D histograms.
void
hist049_Graphics_candle_plot
()
{
gStyle
->
SetTimeOffset
(0);
TDatime
dateBegin
(2010, 1, 1, 0, 0, 0);
TDatime
dateEnd
(2011, 1, 1, 0, 0, 0);
auto
h1
=
new
TH2I
(
"h1"
,
"Machine A + B"
, 12,
dateBegin
.Convert(),
dateEnd
.Convert(), 1000, 0, 1000);
auto
h2 =
new
TH2I
(
"h2"
,
"Machine B"
, 12,
dateBegin
.Convert(),
dateEnd
.Convert(), 1000, 0, 1000);
h1
->
GetXaxis
()->
SetTimeDisplay
(1);
h1
->
GetXaxis
()->
SetTimeFormat
(
"%d/%m/%y"
);
h1
->
GetXaxis
()->
SetNdivisions
(-6);
h1
->
GetXaxis
()->
SetTitle
(
"Date [day/month/year]"
);
float
Rand
;
for
(
int
i =
dateBegin
.Convert(); i <
dateEnd
.Convert(); i += 86400 * 30) {
for
(
int
j
= 0;
j
< 1000;
j
++) {
Rand
=
gRandom
->
Gaus
(500 + sin(i / 10000000.) * 100, 50);
h1
->
Fill
(i,
Rand
);
Rand
=
gRandom
->
Gaus
(500 + sin(i / 11000000.) * 100, 70);
h2->Fill(i,
Rand
);
}
}
h1
->
SetBarWidth
(0.4);
h1
->
SetBarOffset
(-0.25);
h1
->
SetFillColor
(
kYellow
);
h1
->
SetFillStyle
(1001);
h2
->SetBarWidth(0.4);
h2
->SetBarOffset(0.25);
h2
->SetLineColor(
kRed
);
h2
->SetFillColor(
kGreen
);
auto
c1
=
new
TCanvas
();
h1
->
Draw
(
"candle2"
);
h2
->Draw(
"candle3 same"
);
gPad
->BuildLegend(0.78, 0.695, 0.980, 0.935,
""
,
"f"
);
}
kRed
@ kRed
Definition
Rtypes.h:66
kGreen
@ kGreen
Definition
Rtypes.h:66
kYellow
@ kYellow
Definition
Rtypes.h:66
TRangeDynCast
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Definition
TCollection.h:358
gRandom
R__EXTERN TRandom * gRandom
Definition
TRandom.h:62
gStyle
R__EXTERN TStyle * gStyle
Definition
TStyle.h:442
gPad
#define gPad
Definition
TVirtualPad.h:308
ROOT::Detail::TRangeCast
Definition
TCollection.h:311
TAttAxis::SetNdivisions
virtual void SetNdivisions(Int_t n=510, Bool_t optim=kTRUE)
Set the number of divisions for this axis.
Definition
TAttAxis.cxx:233
TAttFill::SetFillColor
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition
TAttFill.h:38
TAttFill::SetFillStyle
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
Definition
TAttFill.h:40
TAxis::SetTimeDisplay
virtual void SetTimeDisplay(Int_t value)
Definition
TAxis.h:173
TAxis::SetTimeFormat
virtual void SetTimeFormat(const char *format="")
Change the format used for time plotting.
Definition
TAxis.cxx:1159
TCanvas
The Canvas class.
Definition
TCanvas.h:23
TDatime
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
Definition
TDatime.h:37
TH1::SetBarOffset
virtual void SetBarOffset(Float_t offset=0.25)
Set the bar offset as fraction of the bin width for drawing mode "B".
Definition
TH1.h:380
TH1::GetXaxis
TAxis * GetXaxis()
Definition
TH1.h:340
TH1::Fill
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
Definition
TH1.cxx:3315
TH1::Draw
void Draw(Option_t *option="") override
Draw this histogram with options.
Definition
TH1.cxx:3037
TH1::SetBarWidth
virtual void SetBarWidth(Float_t width=0.5)
Set the width of bars as fraction of the bin width for drawing mode "B".
Definition
TH1.h:381
TH2I
2-D histogram with an int per channel (see TH1 documentation)
Definition
TH2.h:227
TNamed::SetTitle
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition
TNamed.cxx:164
TRandom::Gaus
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:275
TStyle::SetTimeOffset
void SetTimeOffset(Double_t toffset)
Change the time offset for time plotting.
Definition
TStyle.cxx:1915
c1
return c1
Definition
legend1.C:41
h1
TH1F * h1
Definition
legend1.C:5
TMVA_SOFIE_GNN_Parser.h2
h2
Definition
TMVA_SOFIE_GNN_Parser.py:188
Date
May 2024
Author
Georg Troska
Definition in file
hist049_Graphics_candle_plot.C
.
tutorials
hist
hist049_Graphics_candle_plot.C
ROOT master - Reference Guide Generated on Thu Feb 13 2025 15:59:31 (GVA Time) using Doxygen 1.10.0