post_plot
post_plot.Rd
Redesign axis. If x.side = 0, y.side = 0, the function just adds text at topright of the graph and reset par() for next graphics and provides outputs (see below).
Provide also positions for legend or additional text on the graph.
Use prior_plot() before this function for initial inactivation of the axis drawings.
Usage
post_plot(
x.side = 0,
x.log.scale = FALSE,
x.categ = NULL,
x.categ.pos = NULL,
x.lab = "",
x.axis.size = 1.5,
x.label.size = 1.5,
x.dist.legend = 0.5,
x.nb.inter.tick = 1,
y.side = 0,
y.log.scale = FALSE,
y.categ = NULL,
y.categ.pos = NULL,
y.lab = "",
y.axis.size = 1.5,
y.label.size = 1.5,
y.dist.legend = 0.5,
y.nb.inter.tick = 1,
text.angle = 90,
tick.length = 0.5,
sec.tick.length = 0.3,
bg.color = NULL,
grid.lwd = NULL,
grid.col = "white",
corner.text = "",
corner.text.size = 1,
just.label.add = FALSE,
par.reset = FALSE,
custom.par = NULL,
safer_check = TRUE
)
Arguments
- x.side
Single integer value indicating the axis at the bottom (1) or top (3) of the region figure. Write 0 for no change.
- x.log.scale
Single logical value. Log scale for the x-axis?
- x.categ
Vector of character indicating the categories when the x-axis is qualitative(stripchart, boxplot).
- x.categ.pos
Numeric vector of identical length than x.categ indicating the position of the categories names. If NULL, this will be 1:length(levels()).
- x.lab
Single character string of the label of the x-axis. If x.side == 0 and x.lab != "", then x.lab is printed.
- x.axis.size
Single positive numeric value to increase or decrease the size of the x axis numbers. Value 1 does not change it, 0.5 decreases by half, 2 increases by 2. Also control the size of displayed categories.
- x.label.size
Single positive numeric value to increase or decrease the size of the x axis legend text. Value 1 does not change it, 0.5 decreases by half, 2 increases by 2.
- x.dist.legend
Single positive numeric value to move x-axis legends away (first number of mgp argument of par() but in inches).
- x.nb.inter.tick
Single positive integer value indicating the number of secondary ticks between main ticks on x-axis (only if not log scale). 0 means no secondary ticks.
- y.side
Single integer of either 0, 2 or 4 value to display the axis at the left (2) or right (4) of the region figure. Write 0 for no change.
- y.log.scale
Single logical value. Log scale for the y-axis?
- y.categ
Vector of character indicating the categories when the y-axis is qualitative(stripchart, boxplot).
- y.categ.pos
Numeric vector of identical length than y.categ indicating the position of the categories names. If NULL, this will be 1:length(levels()).
- y.lab
Label of the y-axis. If y.side == 0 and y.lab != "", then y.lab is printed.
- y.axis.size
Single positive numeric value to increase or decrease the size of the y axis numbers. Value 1 does not change it, 0.5 decreases by half, 2 increases by 2. Also control the size of displayed categories.
- y.label.size
Single positive numeric value to increase or decrease the size of the y axis legend text. Value 1 does not change it, 0.5 decreases by half, 2 increases by 2.
- y.dist.legend
Single positive numeric value to move y-axis legends away (first number of mgp argument of par() but in inches).
- y.nb.inter.tick
Single positive integer value indicating the number of secondary ticks between main ticks on y-axis (only if not log scale). 0 means no secondary ticks.
- text.angle
Single numeric value for the angle of the text when axis is qualitative.
- tick.length
Single positive proportion value indicating the length of the main ticks (1 means complete the distance between the plot region and the axis numbers, 0.5 means half the length, etc., 0 for no ticks).
- sec.tick.length
Single positive proportion value indicating the length of the secondary ticks (1 means complete the distance between the plot region and the axis numbers, 0.5 means half the length, etc., 0 for no ticks).
- bg.color
Background color of the plot region. Either (1) NULL (no color), or (2) a single character string or integer. Color can be a color name (see ?colors() in R), an hexadecimal color code, or an integer (according to palette()). BEWARE: cover/hide an existing plot !
- grid.lwd
Vector of positive numeric values. If non NULL, both activate the grid lines and specify the line widths.
- grid.col
Grid line colors (only if grid.lwd non NULL). Either (1) NULL (no color), or (2) a vector of character strings or integers. Color can be color names (see ?colors() in R), hexadecimal color codes, or integers (according to palette()).
- corner.text
Single character string adding a text at the top right corner of the window.
- corner.text.size
Single positive numeric value to increase or decrease the size of the text. Value 1 does not change it, 0.5 decreases by half, 2 increases by 2.
- just.label.add
Single logical value that just add axis labels (legend). If TRUE, at least (x.side == 0 & x.lab != "") or (y.side == 0 & y.lab != "") must be set to display the corresponding x.lab or y.lab.
- par.reset
Single logical value that resets all the graphics parameters. BEWARE: TRUE can generate display problems, mainly in graphic devices with multiple figure regions.
- custom.par
List that provides the parameters that reset all the graphics parameters. BEWARE: if NULL and par.reset == TRUE, the default par() parameters are used.
- safer_check
Single logical value. Perform some "safer" checks (see https://github.com/safer-r)? If TRUE, checkings are performed before main code running: 1) R classical operators (like "<-") not overwritten by another package because of the R scope and 2) required functions and related packages effectively present in local R lybraries. Set to FALSE if this fonction is used inside another "safer" function to avoid pointless multiple checkings.
Value
A list containing:
- $x.mid.left.dev.region: middle of the left margin of the device region, in coordinates of the x-axis.
- $x.left.dev.region: left side of the left margin (including the potential margin of the device region), in coordinates of the x-axis.
- $x.mid.right.dev.region: middle of the right margin of the device region, in coordinates of the x-axis.
- $x.right.dev.region: right side of the right margin (including the potential margin of the device region), in coordinates of the x-axis.
- $x.mid.left.fig.region: middle of the left margin of the figure region, in coordinates of the x-axis.
- $x.left.fig.region: left side of the left margin, in coordinates of the x-axis.
- $x.mid.right.fig.region: middle of the right margin of the figure region, in coordinates of the x-axis.
- $x.right.fig.region: right side of the right margin, in coordinates of the x-axis.
- $x.left.plot.region: left side of the plot region, in coordinates of the x-axis.
- $x.right.plot.region: right side of the plot region, in coordinates of the x-axis.
- $x.mid.plot.region: middle of the plot region, in coordinates of the x-axis.
- $y.mid.bottom.dev.region: middle of the bottom margin of the device region, in coordinates of the y-axis.
- $y.bottom.dev.region: bottom side of the bottom margin (including the potential margin of the device region), in coordinates of the y-axis.
- $y.mid.top.dev.region: middle of the top margin of the device region, in coordinates of the y-axis.
- $y.top.dev.region: top side of the top margin (including the potential margin of the device region), in coordinates of the y-axis.
- $y.mid.bottom.fig.region: middle of the bottom margin of the figure region, in coordinates of the y-axis.
- $y.bottom.fig.region: bottom of the bottom margin of the figure region, in coordinates of the y-axis.
- $y.mid.top.fig.region: middle of the top margin of the figure region, in coordinates of the y-axis.
- $y.top.fig.region: top of the top margin of the figure region, in coordinates of the y-axis.
- $y.top.plot.region: top of the plot region, in coordinates of the y-axis.
- $y.bottom.plot.region: bottom of the plot region, in coordinates of the y-axis.
- $y.mid.plot.region: middle of the plot region, in coordinates of the y-axis.
- $text: warning text
Author
Gael Millot <gael.millot@pasteur.fr>
Yushi Han <yushi.han2000@gmail.com>
Haiding Wang <wanghaiding442@gmail.com>
Examples
if (FALSE) { # \dontrun{
# Screen devices should not be used in examples
# Example of log axis with redrawn x-axis and y-axis:
prior.par <- prior_plot(param.reinitial = TRUE) ;
plot(1:100) ;
post_plot(x.side = 1, x.lab = "Values", y.side = 2, y.lab = "TEST", y.axis.size = 1, y.label.size = 2, y.dist.legend = 0.6)
} # }