rasterImage

rasterImage(image, xleft, ybottom, xright, ytop, angle=0, interpolate=TRUE)
Create a grid of colors, which could represent pixels of an image or something like a correlation matrix.
  • image – A "raster" object, or an object that can be coerced to a raster object via as.raster (e.g. an array with dimensions d x d x 3).
  • xleft, ybottom, xright, ytop – The boundaries of the raster image.
  • angle – If desired, specify an angle to rotate the raster image. The rotation pivots on the bottom-left corner.
  • interpolate – If TRUE, then automatic smoothing will be done on the raster image.

Continue reading

readPNG (png package)

readPNG(source)
Generate a matrix for a raster image from a PNG image. This is especially interesting since not only can this raster image be added to a plot, but the red-green-blue make-up (see rgb) of each pixel may be viewed in the output of readPNG. It is worth noting that functionality on the Windows platform may require some fussing (see the readPNG help file).
  • source – The file name of the PNG file as a character string. If necessary, include the path to the file.

Continue reading

map (maps package)

map(database=”world”, regions=”.”)
Create high quality maps that may be shaded or projected in a variety of ways. While today’s post just covers generating a basic map, additional arguments may be used for coloring in counties, states, or countries (col, fill), looking at different map projections (projection), among many many other options.
  • database – Usually one of four databases: "world", "usa", "state", "county". More databases are available.
  • regions – By default, all regions in the database will be generated. However, specific regions for plotting may be specified using a vector of character strings.

Continue reading

split.screen, screen

The split.screen function is used to split a plotting window into different rectangular sections called "screens". This is similar to what par(mfrow) does, but it is more general since it allows for some plots to span rows and columns. The screen function is used to select a screen for adding a plot and screen also makes it possible to move back and forth between the screens.
split.screen(figs, screen)
  • figs – Describe the number of rows and columns for a new plot via a numeric vector of length 2. Or, if the screen argument is also set, then specify how that specified screen should be split.
  • screen – If a screen is to be split into pieces, specify the screen number.
screen(n)
  • n – The number of the screen to which plotting commands should be assigned.

Continue reading

par(cex.axis, cex.lab, cex.main, cex.sub)

par(cex.axis=1, cex.lab=1, cex.main=1.2, cex.sub=1)
par sets or adjusts plotting parameters. Here we consider the adjustment of sizes for four text values: axis tick labels (cex.axis), x-y axis labels (cex.lab), main title (cex.main), and subtitle (cex.sub). There is also a cex argument, which scales all of these values simultaneously. See also: par(mfrow), par(mar, mgp, las), and par(char).
  • cex.axis – Specify the size of the tick label numbers/text with a numeric value of length 1.
  • cex.lab – Specify the size of the axis label text with a numeric value of length 1.
  • cex.main – Specify the size of the title text with a numeric value of length 1.
  • cex.sub – Specify the size of the subtitle label with a numeric value of length 1.

Continue reading

legend

legend(x, y=NULL, legend, …)
Add a legend to a plot.
  • x – Two options: (1) Use "topleft", "bottomright", etc. (2) Use an x-coordinate for the top-left corner of the legend. I generally prefer the first option.
  • y – If chose option (1) for x, then skip this argument. If used option (2), then specify the y-coordinate for the top-left corner of the legend.
  • legend – A character vector listing names or descriptions for the plotted characters and/or lines.
  • – Additional arguments that characterize how to distinguish between different plotting characters or lines in the plot. Use arguments like pch, col, lty, and/or lwd. These arguments should be input as vectors, where the vector elements correspond to the legend values.

Continue reading

rgb

rgb(red, green, blue, alpha)
Specify the amount of red, green, and blue for a color in a plot, and add transparency using the alpha level.
  • red – A number (or vector of numbers) between 0 and 1, where higher numbers mean more red.
  • green – A number (or vector of numbers) between 0 and 1, where higher numbers mean more green.
  • blue – A number (or vector of numbers) between 0 and 1, where higher numbers mean more blue.
  • alpha – A number (or vector of numbers) between 0 and 1, where 0 is fully transparent and 1 is opaque.

Continue reading

layout, par(mfrow)

Create a multi-paneled plotting window. The par(mfrow) function is handy for creating a simple multi-paneled plot, while layout should be used for customized panel plots of varying sizes.
par(mfrow)
  • mfrow – A vector of length 2, where the first argument specifies the number of rows and the second the number of columns of plots.
layout(mat, widths=rep(1, ncol(mat)), heights=rep(1, ncol(mat)))
  • mat – A matrix describing the panel layout, where the numbers describe the order in which to add the plots. A zero entry is interpreted as don’t plot anything here.
  • widths – The widths of the panel columns.
  • heights – The heights of the panel rows.

Continue reading