kwd1
1
Hi ROOT team,
I was wondering if it is possible to add page numbers to a .ps file I generate in ROOT?
Skeletized code is as such:
{
TFile f(“histo4.root”,“READ”);
c1 = new TCanvas(“c1”,“sub data”,200,10,700,500);
callanstime1->Draw();c1->Print(“histo4.ps(”,“ps”); c1.Clear();
rzb_tot->Draw("");c1->Print(“histo4.ps(”,“ps”); c1.Clear();
c1->Print(“histo4.ps)”,“ps”); c1.Clear();
}
thanks!
Ken
couet
2
here is a way
{
// Number on pages
char c[10]; int n = 1;
TCanvas* canvas = new TCanvas("canvas", "canvas", 600, 500);
TPostScript *ps = new TPostScript("plots.ps",112);
TH1F* histo = new TH1F("histo","test 1",10,0.,10.);
TLatex l; l.SetTextSize(0.03); l.SetTextAlign(22);
histo->Fill(2.);
histo->Draw();
sprintf(c,"- %d -",n++); l.DrawLatex(5, -0.1, c);
canvas->Update();
ps->NewPage();
histo->Fill(4.);
histo->Draw();
sprintf(c,"- %d -",n++); l.DrawLatex(5, -0.1, c);
canvas->Update();
ps->NewPage();
histo->Fill(6.);
sprintf(c,"- %d -",n++); l.DrawLatex(5, -0.1, c);
canvas->Update();
ps->NewPage();
histo->Fill(8.);
histo->Draw();
sprintf(c,"- %d -",n++); l.DrawLatex(5, -0.1, c);
canvas->Update();
ps->Close();
}
kwd1
3
Hi, thanks!
I was trying to extend your example one way further. It seems in the
l.DrawLatex(5, -0.1, c);
line, you have to specify the coordinates manually based on the coordinates of the histogram.
Is there a way to do it globally? I tried:
histo->Fill(2.);
histo->Draw();
sprintf(c,"- %d -",n++); l.PaintLatex(.5 , .5, 0., .1, c);
canvas->Update();
ps->NewPage();
but for reasons unknown it draws the number and then erases it
and overdraws the plot.
thanks
Ken
couet
4
Better to do it that way:
{
// Number on pages
char c[10]; int n = 1;
TCanvas* canvas = new TCanvas("canvas", "canvas", 600, 500);
TPostScript *ps = new TPostScript("plots.ps",112);
TH1F* histo = new TH1F("histo","test 1",10,0.,10.);
TText l; l.SetTextSize(0.03); l.SetTextAlign(22);
histo->Fill(2.);
histo->Draw();
sprintf(c,"- %d -",n++); l.DrawTextNDC(.5, 0.03, c);
canvas->Update();
ps->NewPage();
histo->Fill(4.);
histo->Draw();
sprintf(c,"- %d -",n++); l.DrawTextNDC(.5, 0.03, c);
canvas->Update();
ps->NewPage();
histo->Fill(6.);
sprintf(c,"- %d -",n++); l.DrawTextNDC(.5, 0.03, c);
canvas->Update();
ps->NewPage();
histo->Fill(8.);
histo->Draw();
canvas->cd();
sprintf(c,"- %d -",n++); l.DrawTextNDC(.5, 0.03, c);
canvas->Update();
ps->Close();
}