car (version 2.0-26)

TransformationAxes: Axes for Transformed Variables

Description

These functions produce axes for the original scale of transformed variables. Typically these would appear as additional axes to the right or at the top of the plot, but if the plot is produced with axes=FALSE, then these functions could be used for axes below or to the left of the plot as well.

Usage

basicPowerAxis(power, base=exp(1), 
    side=c("right", "above", "left", "below"), 
    at, start=0, lead.digits=1, n.ticks, grid=FALSE, grid.col=gray(0.50), 
    grid.lty=2,
    axis.title="Untransformed Data", cex=1, las=par("las"))

bcPowerAxis(power, side=c("right", "above", "left", "below"), 
    at, start=0, lead.digits=1, n.ticks, grid=FALSE, grid.col=gray(0.50), 
    grid.lty=2,
    axis.title="Untransformed Data", cex=1, las=par("las"))
    
yjPowerAxis(power, side=c("right", "above", "left", "below"), 
	at, lead.digits=1, n.ticks, grid=FALSE, grid.col=gray(0.50), 
  grid.lty=2,
	axis.title="Untransformed Data", cex=1, las=par("las"))

probabilityAxis(scale=c("logit", "probit"), 
	side=c("right", "above", "left", "below"),
	at, lead.digits=1, grid=FALSE, grid.lty=2, grid.col=gray(0.50),
    axis.title = "Probability", interval = 0.1, cex = 1, las=par("las"))

Arguments

power
power for Box-Cox, Yeo-Johnson, or simple power transformation.
scale
transformation used for probabilities, "logit" (the default) or "probit".
side
side at which the axis is to be drawn; numeric codes are also permitted: side = 1 for the bottom of the plot, side=2 for the left side, side = 3 for the top, side = 4 for the right side.
at
numeric vector giving location of tick marks on original scale; if missing, the function will try to pick nice locations for the ticks.
start
if a start was added to a variable (e.g., to make all data values positive), it can now be subtracted from the tick labels.
lead.digits
number of leading digits for determining `nice' numbers for tick labels (default is 1.
n.ticks
number of tick marks; if missing, same as corresponding transformed axis.
grid
if TRUE grid lines for the axis will be drawn.
grid.col
color of grid lines.
grid.lty
line type for grid lines.
axis.title
title for axis.
cex
relative character expansion for axis label.
las
if 0, ticks labels are drawn parallel to the axis; set to 1 for horizontal labels (see par).
base
base of log transformation for power.axis when power = 0.
interval
desired interval between tick marks on the probability scale.

Value

  • These functions are used for their side effects: to draw axes.

Details

The transformations corresponding to the three functions are as follows: [object Object],[object Object],[object Object],[object Object] These functions will try to place tick marks at reasonable locations, but producing a good-looking graph sometimes requires some fiddling with the at argument.

References

Fox, J. and Weisberg, S. (2011) An R Companion to Applied Regression, Second Edition, Sage.

See Also

basicPower, bcPower, yjPower, logit.

Examples

Run this code
UN <- na.omit(UN)
par(mar=c(5, 4, 4, 4) + 0.1) # leave space on right

with(UN, plot(log(gdp, 10), log(infant.mortality, 10)))
basicPowerAxis(0, base=10, side="above", 
  at=c(50, 200, 500, 2000, 5000, 20000), grid=TRUE, 
  axis.title="GDP per capita")
basicPowerAxis(0, base=10, side="right",
  at=c(5, 10, 20, 50, 100), grid=TRUE, 
  axis.title="infant mortality rate per 1000")

with(UN, plot(bcPower(gdp, 0), bcPower(infant.mortality, 0)))
bcPowerAxis(0, side="above", 
  grid=TRUE, axis.title="GDP per capita")
bcPowerAxis(0, side="right",
  grid=TRUE, axis.title="infant mortality rate per 1000")

with(UN, qqPlot(logit(infant.mortality/1000)))
probabilityAxis()

with(UN, qqPlot(qnorm(infant.mortality/1000)))
probabilityAxis(at=c(.005, .01, .02, .04, .08, .16), scale="probit")

Run the code above in your browser using DataCamp Workspace