ps.slide {Hmisc} | R Documentation |
The 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
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)
file |
|
filename |
name or character string or character vector specifying file prefix.
For setps or setpdf specify type="char" if this is a
character vector or a quote-delimited character string.
|
string |
a character string to be processed by psfrag in LaTeX.
|
background |
default is yellow on navy blue background (black on white for type=1,3 .
background may also be
set to any legitimate background color listed in the S-supplied object
ps.colors.rgb .
|
foreground |
foreground color. See background for allowable values.
|
font |
font for text. Replaces the first font in the standard list of fonts
in 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 .
|
pointsize |
postscript point size. Set to a larger number if using multiple plots
via par(mfrow=) . |
hor |
default is TRUE to make a horizontal graph
|
lwd |
line width |
mgp |
see par . Defaults are chosen according to type .
|
mar |
margins (see par )
|
pch |
see par
|
view |
set to 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.
|
pcx |
set to TRUE to initiate conversion to pcx format. Also implies
close=TRUE .
|
tiff |
set to TRUE to initiate conversion to tiff format. Also implies
close=TRUE .
|
close |
set to TRUE to finish construction of the postscript file.
|
bty |
box type surrounding graph. Default is "l" for "L" shape. Use
"c" for complete box.
|
type |
For ps.slide , type is an integer. In this case,
set 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 type=4 for overheads.
For setps and setpdf , type="char" specifies that
the filename argument is a character string or vector, and
any other value indicates that it is an unquoted name.
|
height |
defaults to 5 if type=3 , otherwise no default (except for type=4)
|
width |
defaults to 7 if type=3 , otherwise no default (except for type=4)
|
tck |
length of tick marks. See par .
|
las |
set to 0 to have axis labels always parallel to the axis, 1 for
always horizontal, 2 for perpendicular to axis
|
eps |
set to 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.
|
... |
other arguments to ps.options (or postscript for Windows or
pdf.graph for setpdf )
|
w |
width of plot. Default is chosen to scale nicely to h for a
landscape plot
|
h |
height of plot (default is 3in) |
sublines |
number of lines to reserve for subtitles |
toplines |
number of lines to reserve for main title |
leftlines |
number of lines to reserve for left margin |
trellis |
set to 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.
|
setTrellis. |
set to FALSE to prevent setTrellis from being called to set the
strip panel background and to set characteristics for dot plot
reference lines
|
strip.blank |
set to FALSE to keep shading in conditioning variable panel titles, if
setTrellis.=TRUE
|
lty.dot.line |
if setTrellis.=TRUE , the line type for dot plot reference lines (default = solid line)
|
lwd.dot.line |
if setTrellis.=TRUE , the line width for dot plot reference lines
(default = 1)
|
seqno |
if non-null, pastes the value of seqno at the end of the base of the
file name, for setps and setpdf
|
color |
set 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.
|
region |
see pdf.graph . Default is to use an image region that is just large
enough to contain the graphic.
|
ratio |
ratio of width to height of the plot when only one of those is specified. Defaults depend on whether S-Plus or R are being used. |
lref |
LaTeX reference point for string . See the psfrag documentation
referenced below. Default is "c" for centered (this is also the
default for psref ).
|
psref |
PostScript reference point. |
scale |
scall factor, default is 1 |
srt |
rotation for string in degrees (default is zero)
|
nothing, for most of the functions. tex
returns a modified
character string.
Starts a postscript file or a process to convert it to pcx format, or
starts a Trellis postscript device.
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).
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.
postscript
, par
, ps.options
,
mgp.axis.labels
, pdf
, trellis.device
, setTrellis
## 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)