The lwd argument is most commonly used to adjust line width in functions like plot(), lines(), abline(), and other plotting functions, but it can also be used to adjust the line width of plotting characters.
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.
Use an interactive, exploratory plot function with a click-interface and eight graphing options. The type of plots generated are printed out in the console. To exit, click "exit" on the plot.
- dataFrame – A data frame.
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.
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.
- 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.
- n – The number of the screen to which plotting commands should be assigned.
par(cex.axis=1, cex.lab=1, cex.main=1.2, cex.sub=1)
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.
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.
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.
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.
- 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.