00001
00002
00003
00004 void graphpolar()
00005 {
00006
00007
00008 TCanvas * CPol = new TCanvas("CPol","TGraphPolar Examples",1200,600);
00009 CPol->Divide(2,1);
00010 CPol->cd(1);
00011
00012 Double_t xmin=0;
00013 Double_t xmax=TMath::Pi()*2;
00014
00015 Double_t x[1000];
00016 Double_t y[1000];
00017 Double_t x1[20];
00018 Double_t y1[20];
00019
00020 TF1 * fplot = new TF1("fplot","cos(2*x)*cos(20*x)",xmin,xmax);
00021
00022 for (Int_t ipt = 0; ipt < 1000; ipt++){
00023 x[ipt] = ipt*(xmax-xmin)/1000+xmin;
00024 y[ipt] = fplot->Eval(x[ipt]);
00025 }
00026
00027 TGraphPolar * grP = new TGraphPolar(1000,x,y);
00028 grP->SetLineColor(2);
00029 grP->SetLineWidth(0.2);
00030 grP->SetFillStyle(3012);
00031 grP->SetFillColor(2);
00032 grP->Draw("AFL");
00033
00034 for (Int_t ipt = 0; ipt < 20; ipt++){
00035 x1[ipt] = x[1000/20*ipt];
00036 y1[ipt] = y[1000/20*ipt];
00037 }
00038
00039 TGraphPolar * grP1 = new TGraphPolar(20,x1,y1);
00040 grP1->SetMarkerStyle(29);
00041 grP1->SetMarkerSize(2);
00042 grP1->SetMarkerColor(4);
00043 grP1->SetLineColor(4);
00044 grP1->Draw("CP");
00045
00046
00047 CPol->Update();
00048 grP1->GetPolargram()->SetTextColor(8);
00049 grP1->GetPolargram()->SetRangePolar(-TMath::Pi(),TMath::Pi());
00050 grP1->GetPolargram()->SetNdivPolar(703);
00051 grP1->GetPolargram()->SetToRadian();
00052
00053 CPol->cd(2);
00054 Double_t x2[30];
00055 Double_t y2[30];
00056 Double_t ex[30];
00057 Double_t ey[30];
00058 for (Int_t ipt = 0; ipt < 30; ipt++){
00059 x2[ipt] = x[1000/30*ipt];
00060 y2[ipt] = 1.2 + 0.4*sin(TMath::Pi()*2*ipt/30);
00061 ex[ipt] = 0.2+0.1*cos(2*TMath::Pi()/30*ipt);
00062 ey[ipt] = 0.2;
00063 }
00064
00065 TGraphPolar * grPE = new TGraphPolar(30,x2,y2,ex,ey);
00066 grPE->SetMarkerStyle(22);
00067 grPE->SetMarkerSize(1.5);
00068 grPE->SetMarkerColor(5);
00069 grPE->SetLineColor(6);
00070 grPE->SetLineWidth(2);
00071 grPE->Draw("EP");
00072 CPol->Update();
00073 grPE->GetPolargram()->SetTextSize(0.03);
00074 grPE->GetPolargram()->SetTwoPi();
00075 grPE->GetPolargram()->SetToRadian();
00076 }