Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
hist053_Graphics_candle_scaled.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_hist
3/// \notebook
4/// Candle Scaled, illustrates what scaling does on candle and violin charts.
5/// Please try to modify the static functions SetScaledCandle and SetScaledViolin
6///
7/// \macro_image (tcanvas_js)
8/// \macro_code
9///
10/// \date February 2023
11/// \author Georg Troska
12
14{
15 TCanvas *c1 = new TCanvas("c1", "TCandle Scaled", 800, 600);
16 c1->Divide(2, 2);
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 for (int j = 0; j < 100000; j++) {
21 auto myRand1 = gRandom->Gaus(0, 1);
22 auto myRand2 = gRandom->Gaus(0, 1);
24 h3->Fill(myRand1, myRand2);
25 }
26
27 c1->cd(1);
28
29 TCandle::SetScaledCandle(true); /* This is a global option for all existing candles, default is false */
30
31 h1->SetTitle("CandleX scaled");
32 h1->DrawCopy("candleX2");
33 c1->cd(2);
34
35 h3->SetTitle("CandleY scaled");
36 h3->DrawCopy("candleY2");
37
38 TCandle::SetScaledViolin(false); /* This is a global option for all existing violin, default is true */
39 TH2I *h2 = (TH2I *)h1->Clone();
40 h2->SetFillStyle(0);
41 h2->SetFillColor(kGray + 2);
42 h2->SetLineColor(kBlue);
43 TH2I *h4 = (TH2I *)h3->Clone();
44 h4->SetFillStyle(0);
45 h4->SetFillColor(kGray + 2);
46 h4->SetLineColor(kBlue);
47
48 c1->cd(3);
49 h2->SetTitle("ViolinX unscaled");
50 h2->DrawCopy("ViolinX");
51 c1->cd(4);
52 h4->SetTitle("ViolinY unscaled");
53 h4->DrawCopy("ViolinY");
54}
@ kGray
Definition Rtypes.h:65
@ kBlue
Definition Rtypes.h:66
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
R__EXTERN TRandom * gRandom
Definition TRandom.h:62
static void SetScaledViolin(const Bool_t vScale=true)
Static function to set scaling between violin-withs.
Definition TCandle.cxx:235
static void SetScaledCandle(const Bool_t cScale=true)
Static function to set scaling between candles-withs.
Definition TCandle.cxx:225
The Canvas class.
Definition TCanvas.h:23
void SetTitle(const char *title) override
Change/set the title.
Definition TH1.cxx:6716
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
Definition TH1.cxx:3315
virtual TH1 * DrawCopy(Option_t *option="", const char *name_postfix="_copy") const
Copy this histogram and Draw in the current pad.
Definition TH1.cxx:3084
TObject * Clone(const char *newname="") const override
Make a complete copy of the underlying object.
Definition TH1.cxx:2723
2-D histogram with an int per channel (see TH1 documentation)
Definition TH2.h:227
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
return c1
Definition legend1.C:41
TH1F * h1
Definition legend1.C:5