An example how to display PS, EPS, PDF files in canvas. To load a PS file in a TCanvas, the ghostscript program needs to be install.
Author: Valeriy Onoutchin
This notebook tutorial was automatically generated with ROOTBOOK-izer from the macro found in the ROOT repository on Tuesday, March 19, 2024 at 07:10 PM.
set to batch mode -> do not display graphics
gROOT->SetBatch(1);
create a PostScript file
TString dir = gROOT->GetTutorialDir();
dir.Append("/graphics/feynman.C");
gROOT->Macro(dir);
gPad->Print("feynman.eps");
Info in <TCanvas::Print>: eps file feynman.eps has been created
back to graphics mode
gROOT->SetBatch(0);
create an image from PS file
TImage *ps = TImage::Open("feynman.eps");
if (!ps) {
printf("GhostScript (gs) program must be installed\n");
return;
}
new TCanvas("psexam", "Example how to display PS file in canvas", 600, 400);
TLatex *tex = new TLatex(0.06,0.9,"The picture below has been loaded from a PS file:");
tex->Draw();
TPad *eps = new TPad("eps", "eps", 0., 0., 1., 0.75);
eps->Draw();
eps->cd();
ps->Draw("xxx");
Error in <TUnixSystem::SetDisplay>: Can't figure out DISPLAY, set it manually In case you run a remote ssh session, restart your ssh session with: =========> ssh -Y Error in <TUnixSystem::SetDisplay>: Can't figure out DISPLAY, set it manually In case you run a remote ssh session, restart your ssh session with: =========> ssh -Y
Draw all canvases
gROOT->GetListOfCanvases()->Draw()