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.

Example. We create a plot using the default plotting options (e.g. margin width), then we query several par parameters to determine the current plot’s settings.
> set.seed(1)
> plot(1:10, -4:5 + rnorm(10), main="Plot Title")
> par("cex.main")  # character size of plot title
[1] 1.2
> par("usr")       # indicates the boundary of the plotting region
[1]  0.640000 10.360000 -4.999296  5.067454
> par("tcl")       # axis label tick size
[1] -0.5
In later posts, we will examine the role of par in specifying plot settings, exploring those arguments that are often most useful.
Tip. The par(“usr”) command is especially useful when creating custom “fixed” features in a plot. It allows for objects to be placed within the plot window (e.g. take the average of the first two values from par(“usr”) to get x-coordinate that describes the middle of the plot).

Leave a Reply