piechart.C

Go to the documentation of this file.
00001 void piechart()
00002 {
00003    // Pie chart example.
00004    //Authors: Olivier Couet, Guido Volpi
00005    
00006    Float_t vals[] = {.2,1.1,.6,.9,2.3};
00007    Int_t colors[] = {2,3,4,5,6};
00008    Int_t nvals = sizeof(vals)/sizeof(vals[0]);
00009 
00010    TCanvas *cpie = new TCanvas("cpie","TPie test",700,700);
00011    cpie->Divide(2,2);
00012 
00013    TPie *pie1 = new TPie("pie1",
00014       "Pie with offset and no colors",nvals,vals);
00015    TPie *pie2 = new TPie("pie2",
00016       "Pie with radial labels",nvals,vals,colors);
00017    TPie *pie3 = new TPie("pie3",
00018       "Pie with tangential labels",nvals,vals,colors);
00019    TPie *pie4 = new TPie("pie4",
00020       "Pie with verbose labels",nvals,vals,colors);
00021 
00022    cpie->cd(1);
00023    pie1->SetAngularOffset(30.);
00024    pie1->SetEntryRadiusOffset( 4, 0.1);
00025    pie1->SetRadius(.35);
00026    pie1->Draw("3d");
00027 
00028    cpie->cd(2);
00029    pie2->SetEntryRadiusOffset(2,.05);
00030    pie2->SetEntryLineColor(2,2);
00031    pie2->SetEntryLineWidth(2,5);
00032    pie2->SetEntryLineStyle(2,2);
00033    pie2->SetEntryFillStyle(1,3030);
00034    pie2->SetCircle(.5,.45,.3);
00035    pie2->Draw("r");
00036 
00037    cpie->cd(3);
00038    pie3->SetY(.32);
00039    pie3->GetSlice(0)->SetValue(.8);
00040    pie3->GetSlice(1)->SetFillStyle(3031);
00041    pie3->SetLabelsOffset(-.1);
00042    pie3->Draw("3d t nol");
00043    TLegend *pieleg = pie3->MakeLegend();
00044    pieleg->SetY1(.56); pieleg->SetY2(.86);
00045 
00046    cpie->cd(4);
00047    pie4->SetRadius(.2);
00048    pie4->SetLabelsOffset(.01);
00049    pie4->SetLabelFormat("#splitline{%val (%perc)}{%txt}");
00050    pie4->Draw("nol <");
00051 }

Generated on Tue Jul 5 15:44:22 2011 for ROOT_528-00b_version by  doxygen 1.5.1