Logo ROOT  
Reference Guide
piechart.C File Reference

Detailed Description

View in nbviewer Open in SWAN Pie chart example.

void piechart()
{
Float_t vals[] = {.2,1.1,.6,.9,2.3};
Int_t colors[] = {2,3,4,5,6};
Int_t nvals = sizeof(vals)/sizeof(vals[0]);
TCanvas *cpie = new TCanvas("cpie","TPie test",700,700);
cpie->Divide(2,2);
TPie *pie1 = new TPie("pie1",
"Pie with offset and no colors",nvals,vals);
TPie *pie2 = new TPie("pie2",
"Pie with radial labels",nvals,vals,colors);
TPie *pie3 = new TPie("pie3",
"Pie with tangential labels",nvals,vals,colors);
TPie *pie4 = new TPie("pie4",
"Pie with verbose labels",nvals,vals,colors);
cpie->cd(1);
pie1->SetAngularOffset(30.);
pie1->SetEntryRadiusOffset( 4, 0.1);
pie1->SetRadius(.35);
pie1->Draw("3d");
cpie->cd(2);
pie2->SetEntryRadiusOffset(2,.05);
pie2->SetEntryLineColor(2,2);
pie2->SetEntryLineWidth(2,5);
pie2->SetEntryLineStyle(2,2);
pie2->SetEntryFillStyle(1,3030);
pie2->SetCircle(.5,.45,.3);
pie2->Draw("rsc");
cpie->cd(3);
pie3->SetY(.32);
pie3->GetSlice(0)->SetValue(.8);
pie3->GetSlice(1)->SetFillStyle(3031);
pie3->SetLabelsOffset(-.1);
pie3->Draw("3d t nol");
TLegend *pieleg = pie3->MakeLegend();
pieleg->SetY1(.56); pieleg->SetY2(.86);
cpie->cd(4);
pie4->SetRadius(.2);
pie4->SetLabelsOffset(.01);
pie4->SetLabelFormat("#splitline{%val (%perc)}{%txt}");
pie4->Draw("nol <");
}
Authors
Olivier Couet, Guido Volpi

Definition in file piechart.C.

TPie::SetY
void SetY(Double_t)
Set Y value.
Definition: TPie.cxx:1399
TPie::SetCircle
void SetCircle(Double_t x=.5, Double_t y=.5, Double_t rad=.4)
Set the coordinates of the circle that describe the pie:
Definition: TPie.cxx:1210
TPie::SetRadius
void SetRadius(Double_t)
Set the pie chart's radius' value.
Definition: TPie.cxx:1369
colors
Color * colors
Definition: X3DBuffer.c:21
TPie::MakeLegend
TLegend * MakeLegend(Double_t x1=.65, Double_t y1=.65, Double_t x2=.95, Double_t y2=.95, const char *leg_header="")
This method create a legend that explains the contents of the slice for this pie-chart.
Definition: TPie.cxx:770
TPie::SetLabelsOffset
void SetLabelsOffset(Float_t)
Set the distance between the label end the external line of the TPie.
Definition: TPie.cxx:1353
Float_t
float Float_t
Definition: RtypesCore.h:57
Int_t
int Int_t
Definition: RtypesCore.h:45
TPie::SetLabelFormat
void SetLabelFormat(const char *)
This method is used to customize the label format.
Definition: TPie.cxx:1316
TPie
Definition: TPie.h:23
TPad::Divide
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:1166
TPie::SetEntryLineColor
void SetEntryLineColor(Int_t, Int_t)
Set the color for the slice's outline. "i" is the slice number.
Definition: TPie.cxx:1230
TPie::SetEntryLineStyle
void SetEntryLineStyle(Int_t, Int_t)
Set the style for the slice's outline. "i" is the slice number.
Definition: TPie.cxx:1238
TPie::Draw
virtual void Draw(Option_t *option="l")
Draw the pie chart.
Definition: TPie.cxx:276
TPie::SetEntryLineWidth
void SetEntryLineWidth(Int_t, Int_t)
Set the width of the slice's outline. "i" is the slice number.
Definition: TPie.cxx:1246
TPave::SetY2
virtual void SetY2(Double_t y2)
Set the Y2 value.
Definition: TPave.cxx:687
TCanvas::cd
TVirtualPad * cd(Int_t subpadnumber=0)
Set current canvas & pad.
Definition: TCanvas.cxx:704
TPave::SetY1
virtual void SetY1(Double_t y1)
Set the Y1 value.
Definition: TPave.cxx:674
TPieSlice::SetValue
void SetValue(Double_t)
Set the value for this slice.
Definition: TPieSlice.cxx:101
TPie::GetSlice
TPieSlice * GetSlice(Int_t i)
Return the reference to the slice of index 'id'.
Definition: TPie.cxx:714
TPie::SetEntryFillStyle
void SetEntryFillStyle(Int_t, Int_t)
Set the fill style for the "i" slice.
Definition: TPie.cxx:1262
TPie::SetAngularOffset
void SetAngularOffset(Double_t)
Set the global angular offset for slices in degree [0,360].
Definition: TPie.cxx:1193
TCanvas
Definition: TCanvas.h:23
TLegend
Definition: TLegend.h:23
TPie::SetEntryRadiusOffset
void SetEntryRadiusOffset(Int_t, Double_t)
Set the distance, in the direction of the radius of the slice.
Definition: TPie.cxx:1270