Hi Mike,
You can replace your savepad function with this variant
void savePad(const char* pad_name, const char* outdir, const char* tag)
{
//I want to be able to resize the pad here, but don't know how
char name[100];
sprintf(name,"%s%s_%s", outdir, pad_name, tag);
const char* n = gPad->GetName();
cout <<"Write file:\t"<<name<<"\tfor pad:\t"<<n<<endl;
TPad *pad = gPad;
TCanvas *temp = new TCanvas();
TPad *clone = (TPad*)pad->DrawClone();
clone->SetPad(0,0,1,1);
temp->SaveAs(name);
delete temp;
}
Rene Brun
Mike Miller wrote:
>
> Hi All, I would like to do the following. I have a macro that plots
> several different pads which I get by doing TCanvas::Divide. When I save
> the canvas as a .eps it looks great. But, I would also like to save each
> pad individually so that I can view them separately (and insert them into
> a presentation without cropping them out and resizing). I do that via a
> little function which calls gPad->Save(), but that pad gets saved with
> exactly the same location and dimension on it's own .eps file as it has on
> the main canvas. I want to be able to make it large and centered on a
> regular page. Can somebody help me? Here's an example macro to start the
> discussion. Thanks, Mike
>
> #include <iostream>
>
> void savePad(const char* pad_name, const char* outdir, const char* tag)
> {
> //I want to be able to resize the pad here, but don't know how
> char name[100];
> sprintf(name,"%s%s_%s", outdir, pad_name, tag);
> const char* n = gPad->GetName();
> cout <<"Write file:\t"<<name<<"\tfor pad:\t"<<n<<endl;
> gPad->cd();
> gPad->SaveAs(name);
> }
>
> void RootPadExample()
> {
> TCanvas* c1 = new TCanvas("c1","",100,100,300,300);
> c1->Divide(1,2);
>
> c1->cd(1);
> TF1* func = new TF1("func","sin(x)",0., TMath::Pi());
> func->Draw();
> savePad("sin","./","function.eps");
>
> c1->cd(2);
> TF1* func2 = new TF1("func2","cos(x)",0., TMath::Pi());
> func2->Draw();
> savePad("cos","./","function.eps");
>
> c1->SaveAs("TheCanvas.eps");
> }
>
> --
> Michael L. Miller (Yale Physics) michael.miller@yale.edu
>
> Seattle: 206.543.2908 EPE group, 2nd floor physics.
> BNL: 631.344.8342 Building 118 Yale Software
> Yale: 203.432.6615 Room 301 WNSL
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:09 MET