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 trellis.device
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
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.
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)
setps
or setpdf
omit
surrounding quotes unless type="char"
.
}
psfrag
in LaTeX.
}
type=1,3
.
background
may also be
set to any legitimate background color listed in the S-supplied object
ps.colors.rgb
.
}
background
for allowable values.
}
ps.options("fonts")
. If font="Times-Roman"
, the fifth font
(normally Helvetica-Bold
) is set to Times-Bold
. For setpdf
,
font
is a number, and the default is 1
for Helvetica. All
default fonts are Helvetica for setps
, psfig
, and ps.slide
.
}
par(mfrow=)
.}
TRUE
to make a horizontal graph
}
par
. Defaults are chosen according to type
.
}
par
)
}
par
}
TRUE
to initiate a ghostview
run to view the postscript file.
This option will also close out the postscript file (this is done before
viewing). If you have an active ghostview
window for this file already,
you can just type graphics.off()
or dev.off()
to re-create the .ps
file.
ghostview
will then update the image automatically.
}
TRUE
to initiate conversion to pcx
format. Also implies
close=TRUE
.
}
TRUE
to initiate conversion to tiff
format. Also implies
close=TRUE
.
}
TRUE
to finish construction of the postscript file.
}
"l"
for "L"
shape. Use
"c"
for complete box.
}
type=1
to use black on white background, smaller pointsize,
and other settings that are good for making
overhead transparencies and graphs to include in reports. Set type=3
for 5" x 7" landscape plots, and time=4
for overheads.
For setps
and setpdf
, specifies whether filename
is
quoted or not.
}
type=3
, otherwise no default (except for type=4)
}
type=3
, otherwise no default (except for type=4)
}
par
.
}
0
to have axis labels always parallel to the axis, 1
for
always horizontal, 2
for perpendicular to axis
}
TRUE
if you are going to be importing the postscript file to a
system that really cares that it is marked to officially be encapsulated
postscript. If you set eps=TRUE
, you may put only one figure in the file
(see the onefile
argument in postscript
). This applies to UNIX systems
only.
}
ps.options
(or postscript
for Windows or
pdf.graph
for setpdf
)
}
h
for a
landscape plot
}
TRUE
to set up for postscript output for Trellis graphics. This
makes trellis.device("postscript", ...)
be called instead of
postscript(...)
directly, and leaves par
parameters at defaults.
}
FALSE
to prevent setTrellis
from being called to set the
strip panel background and to set characteristics for dot plot
reference lines
}
FALSE
to keep shading in conditioning variable panel titles, if
setTrellis.=TRUE
}
setTrellis.=TRUE
, the line type for dot plot reference lines (default = solid line)
}
setTrellis.=TRUE
, the line width for dot plot reference lines
(default = 1)
}
seqno
at the end of the base of the
file name, for setps
and setpdf
}
color=TRUE
to use a color Trellis device instead of default of
black and white, for setps
. For setpdf
set to TRUE
to get color pdf graphics.
}
pdf.graph
. Default is to use an image region that is just large
enough to contain the graphic.
}
string
. See the psfrag
documentation
referenced below. Default is "c"
for centered (this is also the
default for psref
).
}
string
in degrees (default is zero)
}tex
returns a modified
character string.ps.slide
Stores a system option ps.slide.file
. pdf.graph
opens
a graphics file using pdf.graph
. setps
creates a function topdf
in frame 0 (the session database).
}
[object Object],[object Object],[object Object]
postscript
, par
, ps.options
,
mgp.axis.labels
, pdf
, trellis.device
, setTrellis
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}