makefig {cmrutils}R Documentation

Helper Plotting Routine


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


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



A function which does the actual plotting.


Additional arguments passed to plotfun.


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.


The scaling factor. Is 1 for the default pointsize.


The base font size in points.


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


The font family for PDF device (see 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.


Returns the result value of call to plotfun invisibly.

See Also, pdf, svg,

Paul Murrell (2005?) Using Computer Modern Fonts in R Graphics.


  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]