ROOT
master
Reference Guide
Loading...
Searching...
No Matches
hist054_Graphics_logscales.C File Reference
Tutorials
»
Histograms tutorials
Detailed Description
Draw parametric functions with log scales.
void
hist054_Graphics_logscales
()
{
TCanvas
*
c1
=
new
TCanvas
(
"c1"
,
"Various options on LOG scales plots"
, 0, 0, 700, 900);
c1
->SetFillColor(30);
TPad
*
pad1
=
new
TPad
(
"pad1"
,
"pad1"
, 0.03, 0.62, 0.50, 0.92, 32);
TPad
*
pad2
=
new
TPad
(
"pad2"
,
"pad2"
, 0.51, 0.62, 0.98, 0.92, 33);
TPad
*
pad3
=
new
TPad
(
"pad3"
,
"pad3"
, 0.03, 0.02, 0.97, 0.535, 38);
pad1
->Draw();
pad2
->Draw();
pad3
->Draw();
TPaveLabel
*title =
new
TPaveLabel
(0.1, 0.94, 0.9, 0.98,
"Various options on LOG scales plots"
);
title->
SetFillColor
(16);
title->
SetTextFont
(42);
title->
Draw
();
TPaveText
*
pave
=
new
TPaveText
(0.1, 0.55, 0.9, 0.61);
pave
->SetFillColor(42);
pave
->SetTextAlign(12);
pave
->SetTextFont(42);
pave
->AddText(
"When more Log labels are requested, the overlapping labels are removed"
);
pave
->Draw();
pad1
->cd();
pad1
->SetLogy();
pad1
->SetGridy();
TF1
*
f1
=
new
TF1
(
"f1"
,
"x*sin(x)*exp(-0.1*x)+15"
, -10., 10.);
TF1
*f2 =
new
TF1
(
"f2"
,
"(sin(x)+cos(x))**5+15"
, -10., 10.);
TF1
*f3 =
new
TF1
(
"f3"
,
"(sin(x)/(x)-x*cos(x))+15"
, -10., 10.);
f1
->
SetLineWidth
(1);
f1
->
SetLineColor
(2);
f2->
SetLineWidth
(1);
f2->
SetLineColor
(3);
f3->
SetLineWidth
(1);
f3->
SetLineColor
(4);
f1
->
Draw
();
f2->
Draw
(
"same"
);
f3->
Draw
(
"same"
);
f1
->
GetYaxis
()->
SetMoreLogLabels
();
TPaveText
*
pave1
=
new
TPaveText
(-6, 2, 6, 6);
pave1
->SetFillColor(42);
pave1
->SetTextAlign(12);
pave1
->SetTextFont(42);
pave1
->AddText(
"Log scale along Y axis."
);
pave1
->AddText(
"More Log labels requested."
);
pave1
->Draw();
pad2
->cd();
double
x
[10] = {200, 300, 400, 500, 600, 650, 700, 710, 900, 1000};
double
y
[10] = {200, 1000, 900, 400, 500, 250, 800, 150, 201, 220};
TGraph
*
g_2
=
new
TGraph
(10,
x
,
y
);
g_2
->Draw(
"AL*"
);
g_2
->SetMarkerColor(2);
g_2
->GetYaxis()->SetMoreLogLabels();
g_2
->GetYaxis()->SetNoExponent();
pad2
->SetLogy();
g_2
->GetXaxis()->SetMoreLogLabels();
pad2
->SetLogx();
pad2
->SetGridx();
TPaveText
*
pave2
=
new
TPaveText
(150, 80, 500, 180);
pave2
->SetFillColor(42);
pave2
->SetTextFont(42);
pave2
->SetTextAlign(12);
pave2
->AddText(
"Log scale along X and Y axis."
);
pave2
->AddText(
"More Log labels on both."
);
pave2
->AddText(
"No exponent along Y axis."
);
pave2
->Draw();
pad3
->cd();
pad3
->SetGridx();
pad3
->SetGridy();
pad3
->SetLogy();
pad3
->SetLogx();
TF1
*f4 =
new
TF1
(
"f4a"
,
"x*sin(x+10)+25"
, 1, 21);
f4->
SetLineWidth
(1);
f4->
Draw
();
f4->
SetNpx
(200);
f4->
GetYaxis
()->
SetMoreLogLabels
();
f4->
GetXaxis
()->
SetMoreLogLabels
();
f4 =
new
TF1
(
"f4b"
,
"x*cos(x+10)*sin(x+10)+25"
, 1, 21);
f4->
SetLineWidth
(1);
f4->
Draw
(
"same"
);
f4->
SetNpx
(200);
Int_t
a
= 20;
for
(
int
i =
a
; i >= 1; i--) {
f4 =
new
TF1
(
Form
(
"f4b_%d"
, i),
"x*sin(x+10)*[0]/[1]+25"
, 1, 21);
f4->
SetParameter
(0, i);
f4->
SetParameter
(1,
a
);
f4->
SetNpx
(200);
f4->
SetLineWidth
(1);
f4->
SetLineColor
(i + 10);
f4->
Draw
(
"same"
);
f4 =
new
TF1
(
Form
(
"f4c_%d"
, i),
"x*cos(x+10)*sin(x+10)*[0]/[1]+25"
, 1, 25);
f4->
SetParameter
(0, i);
f4->
SetParameter
(1,
a
);
f4->
SetNpx
(200);
f4->
SetLineWidth
(1);
f4->
SetLineColor
(i + 30);
f4->
Draw
(
"same"
);
}
TPaveText
*
pave3
=
new
TPaveText
(1.2, 8, 9, 15);
pave3
->SetFillColor(42);
pave3
->AddText(
"Log scale along X and Y axis."
);
pave3
->SetTextFont(42);
pave3
->SetTextAlign(12);
pave3
->AddText(
"More Log labels on both."
);
pave3
->AddText(
"The labels have no exponents (they would be 0 or 1)"
);
pave3
->Draw();
}
a
#define a(i)
Definition
RSha256.hxx:99
Int_t
int Int_t
Definition
RtypesCore.h:45
TRangeDynCast
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Definition
TCollection.h:358
Form
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition
TString.cxx:2489
ROOT::Detail::TRangeCast
Definition
TCollection.h:311
TAttFill::SetFillColor
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition
TAttFill.h:38
TAttLine::SetLineWidth
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
Definition
TAttLine.h:45
TAttLine::SetLineColor
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition
TAttLine.h:42
TAttText::SetTextFont
virtual void SetTextFont(Font_t tfont=62)
Set the text font.
Definition
TAttText.h:48
TAxis::SetMoreLogLabels
void SetMoreLogLabels(Bool_t more=kTRUE)
Set the kMoreLogLabels bit flag When this option is selected more labels are drawn when in log scale ...
Definition
TAxis.h:225
TCanvas
The Canvas class.
Definition
TCanvas.h:23
TF1
1-Dim function class
Definition
TF1.h:233
TF1::GetYaxis
TAxis * GetYaxis() const
Get y axis of the function.
Definition
TF1.cxx:2411
TF1::SetNpx
virtual void SetNpx(Int_t npx=100)
Set the number of points used to draw the function.
Definition
TF1.cxx:3433
TF1::Draw
void Draw(Option_t *option="") override
Draw this function with its current attributes.
Definition
TF1.cxx:1333
TF1::SetParameter
virtual void SetParameter(Int_t param, Double_t value)
Definition
TF1.h:667
TF1::GetXaxis
TAxis * GetXaxis() const
Get x axis of the function.
Definition
TF1.cxx:2400
TGraph
A TGraph is an object made of two arrays X and Y with npoints each.
Definition
TGraph.h:41
TPad
The most important graphics class in the ROOT system.
Definition
TPad.h:28
TPaveLabel
A Pave (see TPave) with a text centered in the Pave.
Definition
TPaveLabel.h:20
TPaveLabel::Draw
void Draw(Option_t *option="") override
Draw this pavelabel with its current attributes.
Definition
TPaveLabel.cxx:88
TPaveText
A Pave (see TPave) with text, lines or/and boxes inside.
Definition
TPaveText.h:21
y
Double_t y[n]
Definition
legend1.C:17
c1
return c1
Definition
legend1.C:41
x
Double_t x[n]
Definition
legend1.C:17
f1
TF1 * f1
Definition
legend1.C:11
Date
July 2016
Author
Olivier Couet
Definition in file
hist054_Graphics_logscales.C
.
tutorials
hist
hist054_Graphics_logscales.C
ROOT master - Reference Guide Generated on Mon Jan 20 2025 04:13:38 (GVA Time) using Doxygen 1.10.0