Axis functions are used to add axes to a chart, different from the traditional x and Y axes, and axis allows the addition of axes in the upper, lower, left, and right 4 directions
Take the x-axis for example, an axis contains 3 elements, a horizontal line, called axis line, tick marks, called tick lines, corresponding labels labels
Basic usage:
Use the side parameter to set the direction of the axis you want to add, starting at the bottom and counterclockwise, with a number from 1 to 4
code example:
Par (OMA = C (1, 1, 1, 1), Mfrow = C (1, 4)) plot (1:5, 1:5, Xlim = C (0,6), Ylim = C (0,6), type = "n", axes = F) text (x = 3, y = 3, labels = "side = 1", CeX = 2) box () axis (side = 1) plot (1:5, 1:5, Xlim = C (0,6), Ylim = C (0,6), type = "n", axes = F) te XT (x = 3, y = 3, labels = "side = 2", CeX = 2) box () axis (side = 2) plot (1:5, 1:5, Xlim = C (0,6), Ylim = C (0,6), type = "N", axes = F) text (x = 3, y = 3, labels = "side = 3", CeX = 2) box () axis (side = 3) plot (1:5, 1:5, Xlim = C (0,6), Ylim = C (0,6), Type = "N", axes = F) text (x = 3, y = 3, labels = "side = 4", CeX = 2) box () axis (side = 4)
As follows:
Parameter settings:
At: A value that needs to be added to the scale, by default a few appropriate ticks are calculated based on the range of variables, or you can manually specify
code example:
Plot (1:5, 1:5, Xlim = C (0,6), Ylim = C (0,6), type = "n", axes = F) box () axis (side = 1, at = C (0, 2, 4, 6))
As follows:
Lables: Specifies the content that needs to be marked on the scale, by default the value corresponding to the scale
code example:
Plot (1:5, 1:5, Xlim = C (0,6), Ylim = C (0,6), type = "n", axes = F) box () axis (side = 1, at = C (0, 2, 4, 6), labels = paste ( C (0, 2, 4, 6), "A", Sep = "")
As follows:
TICK: Logical value, whether the axis is displayed, including tick marks and corresponding axes, FALSE means not showing
code example:
Plot (1:5, 1:5, Xlim = C (0,6), Ylim = C (0,6), type = "n", axes = f) axis (side = 1, tick = f)
:
Line: The location of the axis
code example:
Plot (1:5, 1:5, Xlim = C (0,6), Ylim = C (0,6), type = "n", axes = F) box () axis (side = 1, line = 1)
As follows:
LWD: Sets the width of axis line and tick line
code example:
Plot (1:5, 1:5, Xlim = C (0,6), Ylim = C (0,6), type = "n", axes = F) box () axis (side = 1, line = 1, LWD = 2)
As follows:
Lwd.tick: Set the width of the tick line
code example:
Plot (1:5, 1:5, Xlim = C (0,6), Ylim = C (0,6), type = "n", axes = F) box () axis (side = 1, line = 1, LWD = 1, Lwd.tick = 2)
As follows:
Lty: Sets the line type for axis lines and ticks
code example:
Plot (1:5, 1:5, Xlim = C (0,6), Ylim = C (0,6), type = "n", axes = F) box () axis (side = 1, line = 1, lty = 3)
As follows:
Col: Sets the line color for axis lines and Tick.line
code example:
Plot (1:5, 1:5, Xlim = C (0,6), Ylim = C (0,6), type = "n", axes = F) box () axis (side = 1, line = 1, col = "Blue")
As follows:
Col.ticks: Set the color of the tick line
code example:
Plot (1:5, 1:5, Xlim = C (0,6), Ylim = C (0,6), type = "n", axes = F) box () axis (side = 1, line = 1, col = "Blue", Col.ticks = "Red")
As follows:
POS: Adjusts the position of the axis and overwrites the value of the line parameter when POS sets the corresponding value
code example:
Plot (1:5, 1:5, Xlim = C (0,6), Ylim = C (0,6), type = "n", axes = F) box () axis (side = 1, pos = 1)
As follows:
R language Low-level drawing function-axis