To generate a Postscript (or encapsulated ps) file corresponding to a single image in a canvas, you can:
c1->Print("xxx.ps") or c1->Print("xxx.eps")
This will generate a file corresponding to the picture in the canvas pointed by c1.
pad1->Print("xxx.ps")
prints only the picture in the pad pointed by pad1. The size of the Postcript picture, by default, is computed to keep the aspect ratio of the picture on the screen, where the size along x is always 20cm. You can set the size of the PostScript picture before generating the picture with a command such as:
TPostScript myps("myfile.ps",111);
myps.Range(xsize,ysize);
object->Draw();
myps.Close();
You can set the default paper size with:
gStyle->SetPaperSize(xsize,ysize);
You can resume writing again in this file with myps.Open();. Note that you may have several Postscript files opened simultaneously.
` : go to greek
' : go to special
~ : go to ZapfDingbats
? : go to subscript
^ : go to superscript
! : go to normal level of script
& : backspace one character
# : end of greek or of ZapfDingbats
These special characters are printed as such on the screen. To generate one of these characters on the Postscript file, you must escape it with the escape character "@".
The use of these special characters is illustrated in several macros referenced by the TPostScript constructor.
The following sequence writes the canvas to "c1.ps" and closes the ps file:
TCanvas c1("c1");
h1.Draw();
c1.Print("c1.ps");
If the Postscript file name finishes with "(", the file remains opened (it is not closed). If the Postscript file name finishes with ")" and the file has been opened with "(", the file is closed.
Example:
{
TCanvas c1("c1");
h1.Draw();
c1.Print("c1.ps("); // write canvas and keep the ps file open
h2.Draw();
c1.Print("c1.ps"); // canvas is added to "c1.ps"
h3.Draw();
c1.Print("c1.ps)"); // canvas is added to "c1.ps" and ps file is closed
}
The TCanvas::Print("file.ps(") mechanism is very useful, but it can be a little inconvenient to have the action of opening/closing a file being atomic with printing a page. Particularly if pages are being generated in some loop one needs to detect the special cases of first and last page and then munge the argument to Print() accordingly.
The "[" and "]" can be used instead of "(" and ")" as shown below.
Example:
c1.Print("file.ps["); // No actual print, just open file.ps
for (int i=0; i<10; ++i) {
// fill canvas for context i
// ...
c1.Print("file.ps"); // Actually print canvas to the file
} // end loop
c1.Print("file.ps]"); // No actual print, just close the file
GV.antialias: Falsein the ~/.gv file.
convert +antialias c1.ps c1.gifThe valid patterns are: