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

color

Generates color output. This is the default.

grayscale

Converts colors to grayscale.

greyscale

Alternative spelling of grayscale.

monochrome

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

epsi

All platforms

wmf

Windows

tiff

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

-center boolean

center

Center

Controls whether the plot is centered on the page. The default is yes.

-colormap arrayName

colorMap

ColorMap

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.

-colormode mode

colorMode

ColorMode

Selects the output color mode. Accepted values are non-empty prefixes of color, grayscale, greyscale, and monochrome. The default is color.

-decorations boolean

decorations

Decorations

Controls whether graph backgrounds and 3-D borders are included in the PostScript output. The default is yes.

-fontmap arrayName

fontMap

FontMap

Specifies the name of a Tcl array used to map Tk fonts to PostScript fonts. An empty value uses automatic font translation.

-footer boolean

footer

Footer

Controls whether identifying information such as the date, user, and host is printed in the PostScript footer. The default is no.

-height distance

height

Height

Specifies the requested height of the PostScript plot. 0 uses the current graph height. The default is 0.

-landscape boolean

landscape

Landscape

Controls whether the plot is generated in landscape orientation. The default is no.

-maxpect boolean

maxpect

Maxpect

Controls whether the plot is scaled to the largest size that fits on the page while preserving its aspect ratio. The default is no.

-padx padding

padX

PadX

Specifies horizontal page padding as one or two non-negative screen distances. The default is 1.0i.

-pady padding

padY

PadY

Specifies vertical page padding as one or two non-negative screen distances. The default is 1.0i.

-paperheight distance

paperHeight

PaperHeight

Specifies the positive paper height. The default is 11.0i.

-paperwidth distance

paperWidth

PaperWidth

Specifies the positive paper width. The default is 8.5i.

-preview boolean

preview

Preview

Controls whether a preview image is included in the generated output. The default is no.

-previewformat format

previewFormat

PreviewFormat

Selects the preview format. Accepted values are non-empty prefixes of the formats supported on the current platform: epsi, wmf, and tiff. The default is epsi.

-width distance

width

Width

Specifies the requested width of the PostScript plot. 0 uses the current graph width. The default is 0.

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