logscales.C

Go to the documentation of this file.
00001 void logscales() {
00002 //Draw parametric functions with log scales
00003 //Author: Olivier Couet
00004    
00005    TCanvas *c1 = new TCanvas("c1",
00006       "Various options on LOG scales plots",0,0,700,900);
00007    c1->SetFillColor(30);
00008 
00009    pad1 = new TPad("pad1","pad1",0.03,0.62,0.50,0.92,32);
00010    pad2 = new TPad("pad2","pad2",0.51,0.62,0.98,0.92,33);
00011    pad3 = new TPad("pad3","pad3",0.03,0.02,0.97,0.535,38);
00012    pad1->Draw(); pad2->Draw(); pad3->Draw();
00013 
00014    title = new TPaveLabel(0.1,0.94,0.9,0.98,
00015       "Various options on LOG scales plots");
00016    title->SetFillColor(16);
00017    title->SetTextFont(42);
00018    title->Draw();
00019 
00020    pave = new TPaveText(0.1,0.55,0.9,0.61);
00021    pave->SetFillColor(42);
00022    pave->SetTextAlign(12);
00023    pave->SetTextFont(42);
00024    pave->AddText("When more Log labels are requested, the overlaping \
00025       labels are removed");
00026    pave->Draw();
00027 
00028    pad1->cd();
00029    pad1->SetLogy();
00030    pad1->SetGridy();
00031    TF1 *f1 = new TF1("f1","x*sin(x)*exp(-0.1*x)+15",-10.,10.);
00032    TF1 *f2 = new TF1("f2","(sin(x)+cos(x))**5+15",-10.,10.);
00033    TF1 *f3 = new TF1("f3","(sin(x)/(x)-x*cos(x))+15",-10.,10.);
00034    f1->SetLineWidth(1); f1->SetLineColor(2);
00035    f2->SetLineWidth(1); f2->SetLineColor(3);
00036    f3->SetLineWidth(1); f3->SetLineColor(4);
00037    //f1->SetTitle("");
00038    f1->Draw();
00039    f2->Draw("same");
00040    f3->Draw("same");
00041    f1->GetYaxis()->SetMoreLogLabels();
00042    pave1 = new TPaveText(-6,2,6,6);
00043    pave1->SetFillColor(42);
00044    pave1->SetTextAlign(12);
00045    pave1->SetTextFont(42);
00046    pave1->AddText("Log scale along Y axis.");
00047    pave1->AddText("More Log labels requested.");
00048    pave1->Draw();
00049 
00050    pad2->cd();
00051    double x[10] = { 200, 300, 400, 500, 600, 650, 700, 710, 900,1000 };
00052    double y[10] = { 200, 1000, 900, 400, 500, 250, 800, 150, 201, 220 };
00053    g_2 = new TGraph(10,x,y);
00054    //g_2->SetTitle("");
00055    g_2->Draw("AL*");
00056    g_2->SetMarkerColor(2);
00057    g_2->GetYaxis()->SetMoreLogLabels();
00058    g_2->GetYaxis()->SetNoExponent();
00059    pad2->SetLogy();
00060    g_2->GetXaxis()->SetMoreLogLabels();
00061    pad2->SetLogx();
00062    pad2->SetGridx();
00063    pave2 = new TPaveText(150,80,500,180);
00064    pave2->SetFillColor(42);
00065    pave2->SetTextFont(42);
00066    pave2->SetTextAlign(12);
00067    pave2->AddText("Log scale along X and Y axis.");
00068    pave2->AddText("More Log labels on both.");
00069    pave2->AddText("No exponent along Y axis.");
00070    pave2->Draw();
00071 
00072    pad3->cd();
00073    pad3->SetGridx();
00074    pad3->SetGridy();
00075    pad3->SetLogy();
00076    pad3->SetLogx();
00077    TF1 *f4 = new TF1("f4a","x*sin(x+10)+25",1,21); 
00078    f4->SetLineWidth(1); 
00079    f4->Draw();
00080    f4->SetNpx(200);
00081    //f4->SetTitle("");
00082    f4->GetYaxis()->SetMoreLogLabels();
00083    f4->GetXaxis()->SetMoreLogLabels();
00084    f4 = new TF1("f4b","x*cos(x+10)*sin(x+10)+25",1,21); 
00085    f4->SetLineWidth(1); f4->Draw("same");
00086    f4->SetNpx(200);
00087    Int_t a = 20;
00088    for (int i=a; i>=1; i--) {
00089      f4 = new TF1(Form("f4b_%d",i),"x*sin(x+10)*[0]/[1]+25",1,21);
00090      f4->SetParameter(0,i);
00091      f4->SetParameter(1,a);
00092         f4->SetNpx(200);
00093      f4->SetLineWidth(1); f4->SetLineColor(i+10); 
00094      f4->Draw("same");
00095      f4 = new TF1(Form("f4c_%d",i),"x*cos(x+10)*sin(x+10)*[0]/[1]+25",1,25);
00096      f4->SetParameter(0,i);
00097      f4->SetParameter(1,a);
00098         f4->SetNpx(200);
00099      f4->SetLineWidth(1); f4->SetLineColor(i+30); f4->Draw("same");
00100    }
00101    pave3 = new TPaveText(1.2,8,9,15);
00102    pave3->SetFillColor(42);
00103    pave3->AddText("Log scale along X and Y axis.");
00104    pave3->SetTextFont(42);
00105    pave3->SetTextAlign(12);
00106    pave3->AddText("More Log labels on both.");
00107    pave3->AddText("The labels have no exponents (they would be 0 or 1)");
00108    pave3->Draw();
00109 }

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