subplot(fun, x, y, size=c(1, 1), vadj=.5, hadj=.5, pars=NULL)
brush
or
spin
. Desired graphical parameters, such as
cex
or
col
,
should be included inside the plot function arguments.
fun
, in user coordinates (see the
usr
graphical parameter).
If
x
and
y
are of length
1
, they (along with
vadj
and
hadj
)
determine the location of the new plot.
If
x
and
y
are vectors of length
2
, they specify
opposite corners of the plot region. A list containing
x
and
y
values may
be supplied instead (as
x
). If
x
is missing, a call to
locator
is made to determine the placement.
fun
, in inches.
If
size
and
x
are both missing, you are required to enter two points on the
existing plot (with
locator
) to specify the opposite corners
of the plot region.
0
means
bottom or right,
.5
means center,
1
means left or top.
This is only applicable if opposite corners
of the plot region were not specified.
subplot
, and is used
to add to that previous subplot.
par
) that were in effect
for the subplot.
The size specified includes the plot region only;
the tick marks and axis labels are outside of this region.
When used in multiple figure plots, the coordinates refer to the current
plot within the figure.
The returned value can be used to add to the subplot.
If you request it to draw outside the figure region,
subplot
gets
very confused and typically puts the subplot across the whole region.
usa(xlim=c(-76.3, -65), ylim=c(39.2, 47.6)) subpars <- subplot(usa()) # locator is used to place the new plot subplot(box(), pars=subpars) # puts box around the small usa map subplot(box()) # use locator to box the enlarged area text(locator(1), "Enlarged Region") year <- as.integer(dimnames(votes.repub)[[2]]) southwest <- match(c("California", "Nevada", "Utah", "New Mexico", "Arizona", "Colorado"), state.name) fun <- expression({ plot(year, votes.repub[s,], xlab="", ylab="", main="", type="l", cex=.5, xlim=c(1900, 1980), ylim=c(0, 100)) abline(h=50) }) rx <- c(101, 125); ry <- c(30.5, 42.5) usa(xlim=rx, ylim=ry) for(s in southwest) subplot(x=state.center$x[s], y=state.center$y[s], size=c(1.0,.6), fun=fun) title(main="Republican Votes in the Southwest")