makefig {cmrutils}R Documentation

Helper Plotting Routine

Description

Sets up graphical device and plots figure. For PDF device, also takes care of embedding fonts (see Details).

Usage

makefig(plotfun, ..., device = c('default', 'pdf', 'svg'),
        width = 8, height = 6, scale = pointsize/12, pointsize = 12, 
        filename = 'Rplot', family = 'Helvetica')

Arguments

plotfun

A function which does the actual plotting.

...

Additional arguments passed to plotfun.

device

The type of graphical device.

width, height

The unscaled width and height of the graphics region in inches. Actual size is c(width, height)*scale.

scale

The scaling factor. Is 1 for the default pointsize.

pointsize

The base font size in points.

filename

The filename for PDF or SVG device. If "standard" extension is missing, it is added automagically.

family

The font family for PDF device (see Details).

Details

For PDF device, function does font embedding via call to embedFonts. The package provides additional font families "CMRoman", "CMSans" which work nicely with cyrillics. These families are based on CM-Super font package by Vladimir Volovich and CMSYASE symbol font by Paul Murrell.

Both metric (‘*.afm’) and outline (‘*.pfb’) files for the "CMRoman", "CMSans" fonts are provided with the package. This allows to embed these fonts even if they are not installed in the system.

Value

Returns the result value of call to plotfun invisibly.

See Also

dev.new, pdf, svg,

Paul Murrell (2005?) Using Computer Modern Fonts in R Graphics. http://www.stat.auckland.ac.nz/~paul/R/CM/CMR.html

Examples

  x <- rnorm(10)

  myplot <- function(x, legend, ...)
  {
    plot(x, ..., pch = 1)
    legend('bottomright', bg = 'white',
           legend = legend, pch = 1)
  }

  makefig(myplot, x = x, legend = 'Simulation')
  makefig(myplot, x = x, legend = 'Simulation', pointsize = 8)


  makefig(myplot, x = x, legend = 'Simulation',
          device = 'pdf', filename = 'embedding.pdf', family = 'CMSans')

  mapply(makefig, device = c('window', 'pdf', 'svg'),
         MoreArgs = list(plotfun = myplot, x = x, legend = 'Simulation',
           filename = 'test', family = 'CMSans'))


[Package cmrutils version 1.3.1 Index]