#include #include #include #include void testDraw(TCanvas* _obj) { // draw canvas as is _obj->SaveAs("_test.pdf"); // scale axis and draw gStyle->SetLabelOffset(0.005, "X"); gStyle->SetLabelSize(0.06, "X"); //0.04 // int nPads = ( (TList*) _obj->GetListOfPrimitives() )->GetSize(); // for (int i = 0; icd(i); // gPad->GetFrame()->UseCurrentStyle(); // //gPad->GetFrame()->Draw("goff"); // //gPad->Update(); // //gPad->RedrawAxis(); // gPad->Modified(); // gPad->Update(); // } _obj->UseCurrentStyle(); _obj->Update(); _obj->SaveAs("_test_scale.pdf"); } void test() { TRandom *rand = new TRandom(1234); TCanvas *c1 = new TCanvas("c1","c1",800,500); c1->Divide(2,1); //============== // 1st pad c1->cd(1); TH1D *h1 = new TH1D("h1", "h1", 10, 0., 2.); h1->SetLineColor(kBlack); h1->GetXaxis()->SetTitle("x-title"); for (int i = 0; i<10; i++){ h1->SetBinContent( i, rand->Uniform(0.,10.) ); } double x[100], y[100]; int n(20); for (Int_t i=0;iSetLineColor(kRed); h1->Draw("e1"); gr->Draw("L3same"); //============== // 2nd pad c1->cd(2); TH1D *h2 = new TH1D("h2", "h2", 10, 0., 2.); TH1D *h3 = new TH1D("h3", "h3", 10, 0., 2.); h2->SetLineColor(kBlack); h3->SetLineColor(kRed); for (int i = 0; i<10; i++) { h2->SetBinContent( i, rand->Uniform(0.,10.) ); h3->SetBinContent( i, rand->Uniform(0.,10.) ); } h2->Draw("e1"); h3->Draw("e1same"); c1->Update(); //============== // test draw/save // call scale-draw/save testDraw(c1); }