par(mar, mgp, las)

par(mar=c(5.1, 4.1, 4.1, 2.1), mgp=c(3, 1, 0), las=0)
par sets or adjusts plotting parameters. Here we consider the following three parameters: margin size (mar), axis label locations (mgp), and axis label orientation (las).
  • mar – A numeric vector of length 4, which sets the margin sizes in the following order: bottom, left, top, and right. The default is c(5.1, 4.1, 4.1, 2.1).
  • mgp – A numeric vector of length 3, which sets the axis label locations relative to the edge of the inner plot window. The first value represents the location the labels (i.e. xlab and ylab in plot), the second the tick-mark labels, and third the tick marks. The default is c(3, 1, 0).
  • las – A numeric value indicating the orientation of the tick mark labels and any other text added to a plot after its initialization. The options are as follows: always parallel to the axis (the default, 0), always horizontal (1), always perpendicular to the axis (2), and always vertical (3).

Continue reading

pdf, png, dev.off

Initialize a plot that will be written directly to a file using pdf or png. Then create a plot using the usual functions in R. Finally, close the file using the dev.off function. There are also bmp, tiff, and jpeg functions, though the jpeg function has proven less stable than the others.
pdf(filename, width=7, height=7)
  • filename – A character string for the file name, ending in .pdf.
  • width – Width of the image, in inches.
  • width – Height of the image, in inches.
png(filename, width=480, height=480)
  • filename – A character string for the file name, ending in .png.
  • width – Width of the image, in inches.
  • width – Height of the image, in inches.
dev.off()

Continue reading

smoothScatter

smoothScatter(x, y, bandwidth, nrpoints=100)
Create a density plot of bivariate data using smoothScatter.
  • x – Numeric vector for x-coordinate.
  • y – Numeric vector for y-coordinate.
  • bandwidth – A vector of length 1 or 2 specifying the bandwidth in the kernel density estimate. A default bandwidth will be chosen if this argument is not specified.
  • nrpoints – The number of points to explicitly show on the plot.

Continue reading

rug

rug(x, …)
Create a set of tick marks along the base of a plot.
  • x – The values at which to create tick marks
  • – Several additional options are available, including the height of the tick marks (ticksize); the side of the plot that tick marks should be placed, where the default is the bottom (side); line width (lwd); color (col); among others.

Continue reading

par(char)

par(char)
The par function is a useful used for specifying plotting options. Arguments can be provided to set specific options, or a character argument may be specified to query current plot options. This post focuses on the latter purpose, and we’ll revisit many other par options in later posts.
  • char – A character string of a par option.

Continue reading