nicePlot: Utility plotting functions

Description Usage Arguments Details See Also Examples

Description

Functions used in conjunction with plot.sma to customize spacing of ticks on plot axes. defineAxis creates an 'axis' object, including tick spacing, limits, and labels, that can be passed into plot.sma or nicePlot. nicePlot creates an empty plot using x and y axis objects.

Usage

1
2
3
4
defineAxis(major.ticks, limits=NULL, minor.ticks = NULL, 
	major.tick.labels = major.ticks, both.sides = FALSE)
nicePlot(xaxis, yaxis, log = "", ann = par("ann"), xlab = NULL, 
	ylab = NULL,tck = par("tck"),frame.plot = TRUE, ...)

Arguments

limits

the x or y limits of the plot, (x1, x2) or (y1,y2).

major.ticks,minor.ticks

Where to draw major and minor ticks (vectors).

major.tick.labels

Labels to draw at the ticks (optional).

both.sides

a logical value indicating whether tickmarks should also be drawn on opposite sides of the plot, i.e. right or top

xaxis,yaxis

'axis' objects, the result of calling 'defineAxis'.

ann

a logical value indicating whether the default annotation (x and y axis labels) should appear on the plot.

xlab

a label for the x axis, defaults to a description of x.

ylab

a label for the y axis, defaults to a description of y.

log

One of 'x', 'y' or 'xy', specifying which axes draw in log10 scale.

frame.plot

a logical indicating whether a box should be drawn around the plot, by default = TRUE.

tck

The length of tick marks as a fraction of the smaller of the width or height of the plotting region. If tck >= 0.5 it is interpreted as a fraction of the relevant side, so if tck = 1 grid lines are drawn. By default set to current system defaults (tck = par("tck")).

...

Arguments to be passed to nicePlot, and therein to 'axis'.

Details

By default, calls to plot.sma use the values given by plot.default to determine axis limits and spacing of major and minor ticks. Users can override these values by passing two 'axis' objects created by defineAxis to plot.sma. When both x and y axis objects are passed to plot.sma, the function uses nicePlot to construct the axes according to the specified values, instead of plot.default. As a minimum, users must at least one argument (major.ticks) to defineAxis when passing these to plot.sma.

The function nicePlot can also be called to construct a new set of axes according to the specified values. For this to work, axis objects must contain both major.ticks and limits.

See Also

sma, plot.sma

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Load leaf lifetime dataset:
data(leaflife)

#First example of axis spacing
ft <- sma(longev~lma*rain,log="xy",data=leaflife)
xax <- defineAxis(major.ticks=c(50, 100, 200, 400))
yax <- defineAxis(major.ticks=c(0.25, 0.5, 1,2,4,8))
plot(ft, xaxis=xax, yaxis=yax)

#As above, marking axes on both sides
xax <- defineAxis(major.ticks=c(50, 100, 200, 400), both.sides=TRUE)
yax <- defineAxis(major.ticks=c(0.25, 0.5, 1,2,4,8), both.sides=TRUE)
plot(ft, xaxis=xax, yaxis=yax)

#Using labels with log10 spacing and minor tick marks
xax <- defineAxis(limits=c(10, 1E3), major.ticks=seqLog(1, 1000), 
	minor.ticks=makeLogMinor(seqLog(1, 1000)))
yax <- defineAxis(limits=c(1E-1, 1E1), major.ticks=seqLog(1E-2, 10), 
	minor.ticks=makeLogMinor(seqLog(1E-2, 10)))
plot(ft, xaxis=xax, yaxis=yax)

#As above, but using expressions as labels
xax <- defineAxis(limits=c(10, 1E3), major.ticks=seqLog(10, 1000), 
	minor.ticks=makeLogMinor(seqLog(10, 1000)), 
major.tick.labels = parse(text=paste("10^", c( 1,2,3), sep="")), 
	both.sides=FALSE)
yax <- defineAxis(limits=c(1E-1, 1E1), major.ticks=seqLog(1E-1, 10), 
	minor.ticks=makeLogMinor(seqLog(1E-1, 10)), 
major.tick.labels = parse(text=paste("10^", c( -1,0,1), sep="")), 
	both.sides=FALSE)
plot(ft, xaxis=xax, yaxis=yax)

#start an empty plot using nicePlot 
xax <- defineAxis(limits=c(8, 1.2E3), major.ticks=seqLog(1, 1000))
yax <- defineAxis(limits=c(0.8E-1, 1.2E1), major.ticks=seqLog(1E-2, 10))
nicePlot(xax,yax,log='xy')

smatr documentation built on May 2, 2019, 1:04 p.m.