| set_xaxis | R Documentation |
Set the limits, tick marks and scale of the x-axis of the CI columns, and add vertical lines to them.
set_xaxis(plot, xlim, ticks_at, ticks_digits, ticks_minor, x_trans, vline)
plot |
A forest plot object, see |
xlim |
Limits for the x-axis as a vector of length 2, i.e.
|
ticks_at |
Tick mark positions. By default, ticks are computed
automatically: |
ticks_digits |
Number of digits for the tick labels. If an integer is
given, for example |
ticks_minor |
A numeric vector of positions to draw ticks without
labels. It can be a superset of |
x_trans |
Scale of the axis, one of |
vline |
Numeric vector, positions of vertical lines drawn in addition to
the reference line, on the original scale of the x-axis. Their look is set
with |
Arguments left out keep their current value, so the axis can be set in
several calls, and NULL goes back to the default. A single value
applies to all CI columns. To give the columns different settings, provide
a list with one element for each CI column (a vector for
ticks_digits and x_trans), where NA leaves a column at
its default.
This builds the plot again, so it must be used before the plot is edited
with edit_plot, add_text,
insert_text, add_border or
add_grob.
A forest plot object.
forest set_labs
forest_style
library(grid)
# Read provided sample example data
dt <- read.csv(system.file("extdata", "example_data.csv", package = "forestploter"))
dt <- dt[1:6, ]
# Add a blank column for the forest plot to display CI
dt$` ` <- paste(rep(" ", 20), collapse = " ")
p <- forest(dt[, c("Subgroup", " ")],
est = dt$est,
lower = dt$low,
upper = dt$hi,
ci_column = 2,
ref_line = 1)
# Limits and tick marks, with a vertical line at 2
p <- set_xaxis(p, xlim = c(0, 4), ticks_at = c(0.5, 1, 2, 3), vline = 2)
plot(p)
# The axis can be set in several calls, `NULL` goes back to the default
p <- set_xaxis(p, ticks_digits = 1L)
p <- set_xaxis(p, vline = NULL)
# A log scale, where the reference line of `forest()` defaults to 1
plot(set_xaxis(p, x_trans = "log", xlim = c(0.25, 4), ticks_at = c(0.5, 1, 2, 4)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.