RE: Print divided canvas

From: Manuel Mussini <Manuel.Mussini_at_bo.infn.it>
Date: Wed, 31 Oct 2007 14:00:23 +0100


> Hi,
>
> As I said with .C file you cannot print only one Pad after a Divide (see
> my previous answer). But for the .jpg file it works. You should change
> your macro the following way:
>
> canvas->cd(2);
> gPad->Print("a.jpg");
>
> This will produce the image of the 2nd pad only.

Yes, but I'm no more able to print the whole canvas (in a jpg).

   canvas->cd(0);
   canvas->Print("puppa.jpg");
prints only the background! I have to run the script twice to get the 2 pads in it!

Bye...

>
> OC
>
> -----Original Message-----
> From: owner-roottalk_at_root.cern.ch [mailto:owner-roottalk_at_root.cern.ch]
> On Behalf Of Manuel Mussini
> Sent: Tuesday, October 30, 2007 4:59 PM
> To: roottalk_at_lxbuild091.cern.ch
> Subject: RE: [ROOT] Print divided canvas
>
> Sorry but I don't understand what you mean!
>
> A similar problem appears with ".jpg" extention but in a tricky way! If
> I run
> ".x CanvasTest.C" once (the code below) I get a jpg of the background
> ... if I
> run it again (without restarting ROOT) I get the correct output.
>
>
> TCanvas *canvas;
> TH1F *h;
>
> void CanvasTest()
> {
> h = new TH1F("hist", "Histo", 10, 0., 10.);
> canvas = new TCanvas("canv", "Canvas", 0, 0, 800, 400);
> canvas->Divide(2, 1);
> canvas->cd(1);
> h->Draw();
> gPad->Print("puppa1.C");
> canvas->cd(2);
> h->Draw();
> gPad->Print("puppa2.C");
> canvas->cd(0);
> canvas->Print("puppa.jpg");
> }
>
>
> Bye...
>
>
>
> > I see. This cannot work because the Divide() method is applied on the
> TCanvas.
> > So the top TCanvas must to be created.
> >
> >
> > -----Original Message-----
> > From: owner-roottalk_at_lxbuild091.cern.ch [mailto:owner-
> > roottalk_at_lxbuild091.cern.ch] On Behalf Of Manuel Mussini
> > Sent: Monday, October 29, 2007 12:02
> > To: roottalk_at_lxbuild091.cern.ch
> > Subject: RE: [ROOT] Print divided canvas
> >
> > Ooops!
> > I forgot to sai that I'd like to save them as two ".C" macros!
> > This way the canvas is always divided in two!
> > Only with this extension I've this problem!
> > You can see it with this:
> >
> >
> > TCanvas *canvas;
> > TH1F *h;
> > h = new TH1F("hist", "Histo", 10, 0., 10.);
> > canvas = new TCanvas("canv", "Canvas", 0, 0, 800, 400);
> > canvas->Divide(2, 1);
> > canvas->cd(1);
> > h->Draw();
> > gPad->Print("puppa1.C");
> > canvas->cd(2);
> > h->Draw();
> > gPad->Print("puppa2.C");
> >
> >
> >
> > Bye...
> >
> >
> > > -----Original Message-----
> > > From: Olivier Couet [mailto:Olivier.Couet_at_cern.ch]
> > > Sent: Monday, October 29, 2007 11:55
> > > To: Manuel Mussini; roottalk_at_lxbuild091.cern.ch
> > > Subject: RE: [ROOT] Print divided canvas
> > >
> > > Hi,
> > >
> > > After the last Draw() do:
> > >
> > > gPad->Print("a.ps");
> > >
> > > The 2nd pad only will be saved in the file a.ps.
> > >
> > > Cheers, OC.
> > >
> > > -----Original Message-----
> > > From: owner-roottalk_at_root.cern.ch
> [mailto:owner-roottalk_at_root.cern.ch]
> > > On Behalf Of Manuel Mussini
> > > Sent: Monday, October 29, 2007 11:48 AM
> > > To: roottalk_at_lxbuild091.cern.ch
> > > Subject: [ROOT] Print divided canvas
> > >
> > > Hi,
> > > In my code something like this happens:
> > >
> > >
> > > TCanvas *canvas;
> > > TH1F *h;
> > > h = new TH1F("hist", "Histo", 10, 0., 10.);
> > > canvas = new TCanvas("canv", "Canvas", 0, 0, 800, 400);
> > > canvas->Divide(2, 1);
> > > canvas->cd(1);
> > > h->Draw();
> > > canvas->cd(2);
> > > h->Draw();
> > > // ???
> > >
> > >
> > > Instead of "// ???" I'd like to write something to save the subpads
> > > separately!
> > > I tried several ways with "SaveAs" or "Print" but I didn't get what
> I
> > > want!
> > > Which is the best way to do this?
> > >
> > > Thanks!
> > >
> > > Bye...
> >
>
Received on Wed Oct 31 2007 - 14:00:53 CET

This archive was generated by hypermail 2.2.0 : Wed Oct 31 2007 - 17:50:02 CET