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 7in 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 HmiscOverview
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 gscommand is available in UNIX or
gswin32cis 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 |
string |
a character string to be processed by |
background |
default is yellow on navy blue background (black on white for |
foreground |
foreground color. See |
font |
font for text. Replaces the first font in the standard list of fonts
in |
pointsize |
postscript point size. Set to a larger number if using multiple plots
via |
hor |
default is |
lwd |
line width |
mgp |
see |
mar |
margins (see |
pch |
see |
view |
set to ghostviewrun to view the postscript file. This option will also close out the postscript file (this is done before viewing). If you have an active ghostviewwindow for this file already, you can just type graphics.off() or dev.off() to re-create the ‘.ps’ file.
ghostviewwill then update the image automatically. |
pcx |
set to pcxformat. Also implies close=TRUE .
|
tiff |
set to tiffformat. Also implies close=TRUE .
|
close |
set to |
bty |
box type surrounding graph. Default is |
type |
For |
height |
defaults to 5 if |
width |
defaults to 7 if |
tck |
length of tick marks. See |
las |
set to |
eps |
set to |
... |
other arguments to |
w |
width of plot. Default is chosen to scale nicely to |
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 |
setTrellis. |
set to |
strip.blank |
set to |
lty.dot.line |
if |
lwd.dot.line |
if |
seqno |
if non-null, pastes the value of |
color |
set |
region |
see |
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 |
psref |
PostScript reference point. |
scale |
scall factor, default is 1 |
srt |
rotation for |
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)