Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

ps.latex

PostScript/PDF Preview Device with Optional ‘LaTeX’ Touch


Description

All functions start a pseudo PostScript or Acrobat preview device, using postscript or pdf, and further registering the file name for subsequent calls to pdf.end() or ps.end().

Usage

pdf.do(file, paper = "default", width = -1, height = -1, onefile = FALSE,
       title = NULL, version = "1.4", quiet = FALSE, ...)

pdf.latex(file, height = 5 + main.space * 1.25,  width = 9.5,
          main.space=FALSE, lab.space = main.space,
          paper = "special", title = NULL,
          lab=c(10, 10, 7), mgp.lab=c(1.6, 0.7, 0), mar=c(4, 4, 0.9, 1.1), ...)

ps.do(file, width=-1, height=-1, onefile=FALSE, horizontal=FALSE,
      title = NULL, ...)

ps.latex(file, height = 5 + main.space * 1.25,  width = 9.5,
         main.space=FALSE, lab.space = main.space,
         paper = "special", title = NULL,
         lab=c(10, 10, 7), mgp.lab=c(1.6, 0.7, 0), mar=c(4, 4, 0.9, 1.1), ...)

Arguments

file

character giving the PostScript/PDF file name to be written.

height

device height in inches, height * 2.54 are cm. The default is 5 plus 1.25 iff main.space.

width

device width in inches; for this and height, see postscript.

onefile, horizontal

logicals passed to postscript(..) or pdf(..), most probably to be left alone.

title

PostScript/PDF (not plot!) title passed to postscript() or pdf(); by default use a title with R version and file in it.

version

a string describing the PDF version that will be required to view the output, see pdf; our (high) default ensures alpha-transparency.

quiet

logical specifying that some (informative/warning) messages should not be issued.

main.space

logical; if true, leave space for a main title (unusual for LaTeX figures!).

lab.space

logical; if true, leave space for x- and y- labels (by not subtracting from mar).

paper

character (or missing), typically "a4" or "a4r" in non-America, see postscript. Only if this is "special" (or missing) are your choices of width and height completely honored (and this may lead to files that cannot print on A4) with resizing.

lab

integer of length 3, lab[1:2] are desired number of tick marks on x- and y- axis, see par(lab=).

mgp.lab

three decreasing numbers determining space for axis labeling, see par(mgp=), the default is here smaller than usual.

mar

four numbers, indicating marginal space, see par(mar=), the default is here smaller than usual.

...

arguments passed to ps.do() or pdf.do() from ps.latex / pdf.latex and to ps.options from ps.do/pdf.do.

Details

ps.latex and pdf.latex have an additional LaTeX flavor, and just differ by some extra par settings from the *.do siblings: E.g., after ps.do(..) is called, the graphical parameters c("mar", "mgp", "lab") are reset (to values that typically are better than the defaults for LaTeX figures).

Whereas the defaults for paper, width, and height differ between pdf and postscript, they are set such as to provide very similar functionality, for the functions ps.do() and pdf.do(); e.g., by default, both use a full plot on portrait-oriented page of the default paper, as per getOption("papersize").
pdf.do() sets the default paper to "special" when both width and height are specified.

Value

A list with components

old.par

containing the old par values

new.par

containing the newly set par values

Author(s)

Martin Maechler

See Also

Examples

if(interactive()) {

 ps.latex("ps.latex-ex.ps", main= TRUE)
  data(sunspots)
  plot(sunspots,main=paste("Sunspots Data, n=",length(sunspots)),col="red")
 ps.end()

 pdf.latex("pdf.latex-ex.pdf", main= TRUE)
  data(sunspots)
  plot(sunspots,main=paste("Sunspots Data, n=",length(sunspots)),col="red")
 pdf.end()

 ps.do("ps_do_ex.ps")
   example(plot.function)
 ps.end()

 pdf.do("pdf_do_ex.pdf", width=12, height=5)
   plot(sunspots, main="Monthly Sunspot numbers (in Zurich, then Tokyo)")
 pdf.end()
}

sfsmisc

Utilities from 'Seminar fuer Statistik' ETH Zurich

v1.1-11
GPL (>= 2)
Authors
Martin Maechler [aut, cre] (<https://orcid.org/0000-0002-8685-9910>), Werner Stahel [ctb] (Functions: compresid2way(), f.robftest(), last(), p.scales(), p.dnorm()), Andreas Ruckstuhl [ctb] (Functions: p.arrows(), p.profileTraces(), p.res.2x()), Christian Keller [ctb] (Functions: histBxp(), p.tachoPlot()), Kjetil Halvorsen [ctb] (Functions: KSd(), ecdf.ksCI()), Alain Hauser [ctb] (Functions: cairoSwd(), is.whole(), toLatex.numeric()*), Christoph Buser [ctb] (to function Duplicated()), Lorenz Gygax [ctb] (to function p.res.2fact()), Bill Venables [ctb] (Functions: empty.dimnames(), primes()), Tony Plate [ctb] (to inv.seq()), Isabelle Fl<fc>ckiger [ctb], Marcel Wolbers [ctb], Markus Keller [ctb], Sandrine Dudoit [ctb], Jane Fridlyand [ctb], Greg Snow [ctb] (to loessDemo()), Henrik Aa. Nielsen [ctb] (to loessDemo()), Vincent Carey [ctb], Ben Bolker [ctb], Philippe Grosjean [ctb], Fr<e9>d<e9>ric Ibanez [ctb], Caterina Savi [ctb], Charles Geyer [ctb], Jens Oehlschl<e4>gel [ctb]
Initial release
2021-04-03

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.