Logo ROOT   6.14/05
Reference Guide
candlescaled.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_hist
3 /// \notebook
4 /// Candle Scaled, illustrates what scaleing does on candle and violin charts.
5 /// Please try to modify the static functions SetScaledCandle and SetScaledViolin
6 ///
7 /// \macro_image
8 /// \macro_code
9 ///
10 /// \author Georg Troska
11 
12 void candlescaled()
13 {
14  TCanvas *c1 = new TCanvas("c1","TCandle Scaled",800,600);
15  c1->Divide(2,2);
16  TRandom *rng = new TRandom();
17  TH2I *h1 = new TH2I("h1","GausXY",20,-5,5,100,-5,5);
18  TH2I *h3 = new TH2I("h3","GausXY",100,-5,5,20,-5,5);
19 
20  float myRand1;
21  float myRand2;
22 
23  for (int j = 0; j < 100000; j++) {
24  myRand1 = rng->Gaus(0,1);
25  myRand2 = rng->Gaus(0,1);
26  h1->Fill(myRand1, myRand2);
27  h3->Fill(myRand1, myRand2);
28  }
29 
30 
31  c1->cd(1);
32 
33  TCandle::SetScaledCandle(true); /* This is a global option for all existing candles, default is false */
34 
35  h1->SetTitle("CandleX scaled");
36  h1->DrawCopy("candleX2");
37  c1->cd(2);
38 
39  h3->SetTitle("CandleY scaled");
40  h3->DrawCopy("candleY2");
41 
42  TCandle::SetScaledViolin(true); /* This is a global option for all existing violin, default is true */
43  TH2I *h2 = (TH2I*)h1->Clone();
44  h2->SetFillStyle(0);
45  h2->SetFillColor(kGray+2);
46  h2->SetLineColor(kBlue);
47  TH2I *h4 = (TH2I*)h3->Clone();
48  h4->SetFillStyle(0);
49  h4->SetFillColor(kGray+2);
50  h4->SetLineColor(kBlue);
51 
52  c1->cd(3);
53  h2->SetTitle("ViolinX unscaled");
54  h2->DrawCopy("ViolinX");
55  c1->cd(4);
56  h4->SetTitle("ViolinY unscaled");
57  h4->DrawCopy("ViolinY");
58 
59 
60 }
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
return c1
Definition: legend1.C:41
TVirtualPad * cd(Int_t subpadnumber=0)
Set current canvas & pad.
Definition: TCanvas.cxx:688
Definition: Rtypes.h:58
virtual TH1 * DrawCopy(Option_t *option="", const char *name_postfix="_copy") const
Copy this histogram and Draw in the current pad.
Definition: TH1.cxx:3021
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
Definition: TAttFill.h:39
This is the base class for the ROOT Random number generators.
Definition: TRandom.h:27
TH1F * h1
Definition: legend1.C:5
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition: TAttLine.h:40
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition: TAttFill.h:37
static void SetScaledCandle(const Bool_t cScale=true)
Static function to set scaling between candles-withs.
Definition: TCandle.cxx:227
The Canvas class.
Definition: TCanvas.h:31
virtual void Divide(Int_t nx=1, Int_t ny=1, Float_t xmargin=0.01, Float_t ymargin=0.01, Int_t color=0)
Automatic pad generation by division.
Definition: TPad.cxx:1162
static void SetScaledViolin(const Bool_t vScale=true)
Static function to set scaling between violin-withs.
Definition: TCandle.cxx:236
TObject * Clone(const char *newname=0) const
Make a complete copy of the underlying object.
Definition: TH1.cxx:2657
THist< 2, int, THistStatContent > TH2I
Definition: THist.hxx:293
Definition: Rtypes.h:59
virtual void SetTitle(const char *title)
See GetStatOverflows for more information.
Definition: TH1.cxx:6192
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