Two fully interactive scales in web canvas.
Shows two scales drawing for X or Y axis Several objects can be drawn on the frame and one can select which axis is used for drawing Y+ means that Y drawn on right frame side, X+ - X will be drawn on top frame side Several objects can be add to the frame and associated with normal or opposite axis drawing - like using "same,Y+" option
Functionality available only in web-based graphics
{
auto hpe =
new TH1F(
"hpe",
"Use left and right side for Y scale drawing", 100, 0, 10);
hpe->GetYaxis()->SetTitle("Expo");
auto hpg =
new TH1F(
"hpg",
"Gaus distribution", 100, 0, 10);
hpg->GetYaxis()->SetTitle("#color[2]{Gaus1} / #color[3]{Gaus2}");
hpg->GetYaxis()->SetAxisColor(
kRed);
auto hpg2 =
new TH1F(
"hpg2",
"Narrow gaus distribution", 100, 0, 10);
for (int i = 0; i < 25000; i++) {
if (i % 10 == 0)
}
for (int i = 0; i < 10000; i++) {
if ((i >= 2000) && (i < 3000))
}
gr1->SetMinimum(0);
gr1->SetMaximum(5);
gr1->SetTitle("Tow graphs sharing same Y scale, but using different X scales");
gr1->GetXaxis()->SetTitle("Graph1");
gr2->SetLineColor(
kBlue);
gr2->GetXaxis()->SetAxisColor(
kBlue);
gr2->GetXaxis()->SetTitle("Graph2");
gr2->GetXaxis()->SetTitleColor(
kBlue);
auto c1 =
new TCanvas(
"c1",
"Twoscales example", 1200, 800);
if (!
gROOT->IsBatch() && !
c1->IsWeb())
::Warning(
"twoscales.cxx",
"macro may not work without enabling web-based canvas");
c1->GetPad(1)->Add(hpg,
"Y+");
c1->GetPad(1)->Add(hpg2,
"same,Y+");
c1->GetPad(2)->SetTopMargin(0.2);
c1->GetPad(2)->Add(gr1,
"AL");
c1->GetPad(2)->Add(gr2,
"AL,X+");
}
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
R__EXTERN TRandom * gRandom
R__EXTERN TStyle * gStyle
A TGraph is an object made of two arrays X and Y with npoints each.
1-D histogram with a float per channel (see TH1 documentation)
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...
virtual Double_t Exp(Double_t tau)
Returns an exponential deviate.
void SetStatX(Float_t x=0)
Double_t Sin(Double_t)
Returns the sine of an angle of x radians.
- Author
- Sergey Linev
Definition in file twoscales.cxx.