Learn R Programming

tinyplot (version 0.4.1)

tinyAxis: Generic function for adding an axis to a (tiny)plot

Description

Internal function used for adding an axis to a tinyplot call.

Usage

tinyAxis(x = NULL, ..., type = "standard", labeller = NULL)

Arguments

x

an object which indicates the range over which an axis should be drawn

...

arguments to be passed to methods and perhaps then to axis.

type

the type of axis to be drawn; inherited from the xaxt or yaxt arguments of the parent tinyplot() call. One of either: "standard" (default that draws the axis, ticks, and labels), "none" (no axes), "ticks" (only ticks and labels without axis line), "labels" (only labels without ticks and axis line), or "axis" (only axis line and labels but no ticks). Partial matching is allowed, e.g. type = "s".

labeller

a formatting function to be applied to x, e.g. format, toupper, abs, or other custom function (including from the popular scales package). Can also be one of the following convenience strings (symbols), for which common formatting transformations are provided: "percent" ("%"), "comma" (","), "log" ("l"), "dollar" ("$"), "euro" ("€"), or "sterling" ("£").

Details

tinyAxis provides a thin(ish) wrapper around Axis, but with enhanced flexibility to (i) match parameter combinations based on the axis type and plotting theme, (ii) provide better support for date-time variables, and (iii) enable convenient formatting of axis tick labels.

Examples

Run this code
if (FALSE) {

# plot without axes
tinyplot(0:10, axes = "n")
# add x-axis (labels only)
tinyplot:::tinyAxis(x = 0:10, side = 1, type = "l")
# add y-axis (with custom label formatting)
tinyplot:::tinyAxis(x = 0:10, side = 2, type = "s", labeller = "$")
}

Run the code above in your browser using DataLab