Graph PostScript POSTSCRIPT command¶
Commands in this namespace document graph PostScript output.
POSTSCRIPT is used below as a placeholder for:
GRAPHINST postscript
The PostScript component generates an Encapsulated PostScript representation of the graph.
The generated PostScript can either be returned directly:
set ps [.g postscript output]
or written to a file:
.g postscript output graph.eps
The PostScript component is a single graph component. There are no named PostScript objects.
Generating PostScript¶
POSTSCRIPT output generates the complete graph, including the plotting area, axes, elements, grid, markers,
legend, title, and margins.
With no filename, the generated PostScript is returned as the command result:
set data [.g postscript output]
When a filename is supplied, the output is written to that file and the command returns an empty result:
.g postscript output graph.eps
Configuration options may also be supplied directly to output:
.g postscript output graph.eps -landscape yes -colormode grayscale
Options successfully supplied to POSTSCRIPT output become the current PostScript configuration. They are not
temporary options applying only to that output operation.
Output size¶
By default -width and -height are 0, which causes the current graph dimensions to be used.
An explicit output size can be requested:
.g postscript configure -width 6i -height 4i
These dimensions are expressed as Tk screen distances.
The paper dimensions are controlled by -paperwidth and -paperheight. Their defaults correspond to US
Letter paper:
width = 8.5 inches
height = 11 inches
-padx and -pady specify padding between the graph and the paper boundaries. Each value may contain either
one or two Tk screen distances.
A single value applies equally to both sides:
.g postscript configure -padx 1i -pady 1i
Two values specify the two sides independently:
.g postscript configure -padx {0.5i 1i} -pady {0.75i 1.25i}
The default horizontal and vertical padding is one inch on each side.
If the graph together with its padding is larger than the available paper area, it is reduced while preserving its aspect ratio.
-maxpect yes additionally scales the graph to make maximum use of the available paper area while preserving
its aspect ratio, even when the graph would already fit without scaling.
Centering and orientation¶
The graph is centered on the page by default.
.g postscript configure -center yes
-landscape yes selects landscape orientation:
.g postscript configure -landscape yes
The generated EPS header records either portrait or landscape orientation.
Color modes¶
-colormode controls how colors are represented in PostScript.
The supported modes are:
Mode |
Description |
|---|---|
|
Generates color output. This is the default. |
|
Converts colors to grayscale. |
|
Alternative spelling of |
|
Generates monochrome output. |
Non-empty prefixes of these names are also accepted:
.g postscript configure -colormode mono
For example:
.g postscript output graph.eps -colormode grayscale
Color maps¶
-colormap may name a Tcl array containing custom PostScript translations for Tk colors.
Array elements are indexed by Tk color names. If an entry exists, its value is inserted verbatim into the PostScript output in place of Rbc’s normal color conversion. Colors without an entry use the normal automatic conversion.
Because the same color map is consulted for both foreground and background colors, each custom translation should contain complete PostScript code suitable for every context in which that Tk color is used.
An empty -colormap value disables the custom color map.
Font maps¶
-fontmap may name a Tcl array used to override the automatic mapping of Tk fonts to PostScript fonts.
Each array element is indexed by a Tk font name. Its value is a list containing a PostScript font name and, optionally, a point size:
set psFonts(MyGraphFont) {Helvetica 10}
.g postscript configure -fontmap psFonts
If the point size is omitted, Rbc determines the size from the Tk font.
Fonts not found in the specified array are mapped automatically to suitable PostScript fonts.
An empty -fontmap value disables the custom font map.
Decorations¶
-decorations controls whether widget-style backgrounds and borders are reproduced in the PostScript output.
The default is:
-decorations yes
With decorations disabled, the graph and plotting-area backgrounds are cleared rather than reproduced using their configured background colors, and the plotting-area 3-D border is omitted.
For example:
.g postscript output graph.eps -decorations no
Preview images¶
-preview yes requests a preview image in the generated EPS output.
The default preview format is:
-previewformat epsi
epsi is supported on all platforms and embeds a grayscale EPSI preview in the PostScript data.
Additional preview formats are platform dependent:
Format |
Availability |
|---|---|
|
All platforms |
|
Windows |
|
Windows builds compiled with TIFF support |
Non-empty prefixes of the available format names are also accepted.
epsi embeds a grayscale EPSI preview directly in the PostScript data and therefore works both when the
PostScript is returned and when it is written to a file.
On Windows, wmf and, when available, tiff previews are produced only when POSTSCRIPT output writes to a
file. They generate the corresponding binary EPS preview representation rather than an inline EPSI preview.
Preview generation is disabled by default.
PostScript options¶
Option |
Database name |
Database class |
Description |
|---|---|---|---|
|
|
|
Controls whether the plot is centered on the page. The default is |
|
|
|
Specifies the name of a Tcl array used to override PostScript color definitions. An empty value uses the colors generated automatically from the graph’s Tk colors. |
|
|
|
Selects the output color mode. Accepted values are non-empty prefixes of |
|
|
|
Controls whether graph backgrounds and 3-D borders are included in the PostScript output. The default is |
|
|
|
Specifies the name of a Tcl array used to map Tk fonts to PostScript fonts. An empty value uses automatic font translation. |
|
|
|
Controls whether identifying information such as the date, user, and host is printed in the PostScript footer. The default is |
|
|
|
Specifies the requested height of the PostScript plot. |
|
|
|
Controls whether the plot is generated in landscape orientation. The default is |
|
|
|
Controls whether the plot is scaled to the largest size that fits on the page while preserving its aspect ratio. The default is |
|
|
|
Specifies horizontal page padding as one or two non-negative screen distances. The default is |
|
|
|
Specifies vertical page padding as one or two non-negative screen distances. The default is |
|
|
|
Specifies the positive paper height. The default is |
|
|
|
Specifies the positive paper width. The default is |
|
|
|
Controls whether a preview image is included in the generated output. The default is |
|
|
|
Selects the preview format. Accepted values are non-empty prefixes of the formats supported on the current platform: |
|
|
|
Specifies the requested width of the PostScript plot. |
PostScript configuration options may also be supplied through Tk’s option database. The resource name is
postscript and the resource class is Postscript.
For example:
option add *Graph.postscript.Center no
option add *Graph.Postscript.ColorMode grayscale
Copyright (c) George Yashin