ps.slide function has nice defaults to create postscript
images with larger font, thicker lines, and better axis labeling. These
images can be used to make nice slides. There is an option to view the
constructed postscript file using
ghostview, and an option to
initiate a background process to convert the postscript file to a PC
Paintbrush
.pcx file for importing into various PC presentation
graphics packages although with a significant loss in resolution. This
option assumes you have installed various public-domain unix image
conversion programs. You can preview
.pcx files using
e.g.
xli file.pcx &. Specify
type=1 to make nice fullsize
graphs or
type=3 for making 5 x 7" landscape graphs using
14-point type (useful for submitting to journals).
type=2 (the
default) is for color 35mm slides. Use
type=4 to make nice black
and white overhead projection transparancies (portrait mode). This uses
line thickness 4, pointsize 14, height 8, width 7. For
type=3,
numbers on the y-axis are written horizontally (
las defaults to
1
for
type=3).
ps.slide calls
mgp.axis.labels in Hmisc set up axis-specific
defaults for the 2nd
mgp graphical parameter. See
Overview for
Hmisc for help. This is only used automatically for select high-level graphics
functions in Hmisc and Design, as S-Plus only supports a single
distance between tick marks and tick mark labels using
par, and
when
las=1 a larger distance is needed for the y-axis.
See the body of the function for
type-specific default values for many
of the parameters. This function has not been tested for color output on
Windows systems.
setps is a function that makes small postscript plots with minimal
surrounding white space, suitable for inclusion in books and reports.
Internally
setps uses (and defines) the
psfig function by
Antonio Possolo (antonio@atc.boeing.com).
setps is especially good
for including plots in LaTeX.
setps creates a temporary function in the
session database that when invoked will convert a completed postscript
graphics file to a Adobe Acrobat .pdf if you have Ghostscript
installed and in your path (so that the
gs command is available in
UNIX or
gswin32c is available for Windows/NT). Invoke
topdf by
the command
topdf(), or, if you want to convert a graphic other than
the last one created, run
topdf(filename) to convert
filename.ps
to
filename.pdf. If
trellis=TRUE,
setps invokes
with a
postscript device argument, and it does not set any of the
par
parameters. Arguments
3, 4, 5, 7, 9, and 10 to
setps are ignored if
trellis=TRUE. If
options(setpsPrefix="name")
is defined, the
"name" string
will be prefixed to the file name used by
setps.
setpdf uses a
similar option
setpdfPrefix.
setps and
setpdf set
par(mgp=c(2,0.4,0))
if
trellis=FALSE.
setpdf is similar to
setps but for making Adobe Acrobat PDF
graphics files directly. There are a few problems with the S-Plus
pdf.graph
function used by
setpdf, though: (1) the default for
points (open circle) is too large, (2) graphs are not centered
properly, (3) gray scale does not work, and (4) there is some wasted
space at the bottom of the graph. When drawing points, the user may
want to specify
cex=0.7. It may be better to use
setps followed
by
topdf().
tex is a little function to save typing when including
\tex
commands in graphs that are used with the psfrag package in LaTeX to
typeset any LaTeX text inside a postscript graphic.
tex surrounds
the input character string with \tex[options]{}. This is especially
useful for getting Greek letters and math symbols in postscript
graphs. By default
tex returns a string with
psfrag commands
specifying that the string be centered, not rotated, and not specially
enlarged or shrunk.
showPsfrag is used to display (using ghostview) a postscript image
that contained psfrag LaTeX strings, by building a small LaTeX script
and running latex and dvips.
ps.slide(file, background = if (type != 2) "white" else "navy blue",
foreground = if (type == 2) "yellow" else
(if(background == "white") "black" else "white"),
font = "Helvetica", pointsize = c(24, 28, 14, 14)[type],
hor = type != 4, lwd = c(2, 5, 2, 4)[type],
mgp = if(under.unix) list(c(1.8, 0.4, 0), c(1.5, 0.2, 0),
c(2, 0.4, 0), c(1.5, 0.2, 0))[[type]] else
list(c(1.8, 0.5, 0), c(1.5, 0.4, 0), c(2, 0.5, 0),
c(1.5, 0.4, 0))[[type]],
mar = list(c(4, 3, 2, 1) + 0.1, c(5, 4, 2.25, 2) + 0.1,
c(3, 3, 1, 1) + 0.1, c(5, 4, 2.25, 2) + 0.1)[[type]],
pch = 202, view = FALSE, pcx = FALSE, tiff = FALSE,
close = view | pcx | tiff, bty = "l",
type = 2, height = switch(type, NULL, NULL, 5, 8),
width = switch(type, NULL, NULL, 7, 7),
tck = if (type == 3 || !under.unix) -0.013 else par("tck"),
las = if (type == 3) 1 else 0, eps = FALSE, ...)
setps(filename, w=0, h=3, pointsize=10, sublines=0, toplines=0,
type="symbol", lwd=2, font="Helvetica",
leftlines=0, las=1,
trellis=!(missing(setTrellis.) & missing(strip.blank) &
missing(lty.dot.line) & missing(lwd.dot.line)),
setTrellis.=TRUE,
strip.blank =TRUE, lty.dot.line = 1, lwd.dot.line = 1,
seqno=NULL, color=FALSE)
setpdf(filename, w=0, h=4, pointsize=10, sublines=0, toplines=0,
type="symbol", lwd=1.5, font=if(.R.)"Helvetica" else 1,
ratio= if(.R.) 4/3 else (1 + sqrt(5))/2,
leftlines=0, las=1, bty='l', hor=FALSE,
trellis=!(missing(setTrellis.) & missing(strip.blank) &
missing(lty.dot.line) & missing(lwd.dot.line)),
setTrellis.=TRUE,
strip.blank =TRUE, lty.dot.line = 1, lwd.dot.line =1,
region=c(0, 0, h, w), color=FALSE, seqno=NULL, ...)
tex(string, lref='c', psref='c', scale=1, srt=0)
showPsfrag(filename)
tex returns a modified
character string.
Frank Harrell
Department of Biostatistics
Vanderbilt University
f.harrell@vanderbilt.edu
Grant MC, Carlisle (1998): The PSfrag System, Version 3. Full documentation is obtained by searching www.ctan.org for pfgguide.ps.
## Not run:
ps.slide("myslide") # myslide is file name prefix
# use ps.slide("myslide",back="green") to use e.g. green background
plot(x, y)
title("My Title")
ps.slide(view=TRUE) # makes myslide.ps file
# use ps.slide(close=TRUE) to close file without viewing with
# ghostview.
ps.slide(view=TRUE, pcx=TRUE)
# converts myslide.ps into myslide.pcx (PC Paintbrush
# format suitable for importing in PC graphics packages)
mgp.axis.labels(c(.4,1.2)) # override 2nd mgp parameters for x- and y axes
mgp.axis.labels(type='x') # retrieve 3 mgp parameters for x-axis
setps(myfile) # equiv. to setps('myfile', type='char')
# setps(myfile, trellis=TRUE, other args) for Trellis
# plotting commands
dev.off()
topdf() # topdf created by setps
# makes Ghostscript create "myfile.pdf"
setpdf(myfile)
# plotting commands
dev.off()
# Put math and Greek symbols in a graph
setps(test)
x <- seq(0,15,length=100)
plot(x, dchisq(x, 5), xlab=tex('$x$'),
ylab=tex('$f(x)$'), type='l')
title(tex('Density Function of the $\chi_{5}^{2}$ Distribution'))
dev.off()
# To process this file in LaTeX do something like
#\documentclass{article}
#\usepackage[scanall]{psfrag}
#\begin{document}
#\begin{figure}
#\includegraphics{test.ps}
#\caption{This is an example}
#\end{figure}
#\end{document}
## End(Not run)