Make a shape plot with ggplot2
make_shape_plot(
data,
col.x = "x",
col.estimate = "estimate",
col.stderr = "stderr",
col.lci = NULL,
col.uci = NULL,
col.n = NULL,
exponentiate = FALSE,
logscale = exponentiate,
scalepoints = FALSE,
minse = NA,
pointsize = 3,
col.group = NULL,
shape = NULL,
plotcolour = "black",
colour = NULL,
cicolour = colour,
fill = NULL,
ciunder = NULL,
lines = FALSE,
xlims,
ylims,
gap = c(0.025, 0.025),
ext = c(0.025, 0.025),
ratio = 1.5,
base_size = 11,
base_line_size = base_size/22,
stroke = base_size/22,
xbreaks = NULL,
ybreaks = NULL,
xlab = "Risk factor",
ylab = "Estimate (95% CI)",
legend.name = "",
legend.position = "top",
title = "Figure",
printplot = TRUE,
showcode = TRUE,
addcode = NULL,
addaes = NULL,
addarg = NULL,
envir = NULL
)
The data frame containing estimates to be plotted.
Name of column that provides the x-axis value (e.g. exposure, risk factor, dependent variable). (Default: "x")
Name of column that provides point estimates. (Default: "estimate")
Name of column that provides standard errors. (Default: "stderr")
Name of column that provides lower limit of confidence intervals.
Name of column that provides upper limit of confidence intervals.
Name of column that provides number to be plotted below CIs.
Exponentiate estimates (and CIs) before plotting, use log scale on the axis. (Default: FALSE)
Use log scale for vertical axis. (Default: exponentiate)
Should the points be scaled by inverse of the standard error? (Default: FALSE)
Minimum standard error to use when scaling point size. (Default will use minimum in the data.)
The (largest) size of box to use for plotting point estimates. (Default: 3)
Name of column that groups the estimates. (Default: NULL)
Shape of points. An integer, or name of a column of integers. (Default will use shape 22 - squares with fill.)
Colour for non-data aspects of the plot. (Default: "black")
Colour of points. Name of a colour, or name of a column of colour names. (Default will use plotcolour)
Colour of CI lines. Colour of CI lines. Name of a colour, or name of a column of colour names. (Default will use plotcolour)
Fill colour of points. Fill colour of points. Name of a colour, or name of a column of colour names. (Default will use plotcolour)
Plot CI lines before points. A logical value, or name of a column of logical values. (Default will plot CI lines after points.)
Plot lines (linear fit through estimates, weighted by inverse variance). (Default: FALSE)
A numeric vector of length two. The limits of the x-axis.
A numeric vector of length two. The limits of the y-axis.
A numeric vector of length two. The gap between plotting area and axis to the left and bottom of the plot, as a proportion of the x-axis length. (Default: c(0.025, 0.025))
A numeric vector of length two. The extensions to add to the right and top of the plot, as a proportion of the x-axis length. (Default: c(0.025, 0.025))
The ratio (y-axis:x-axis) to use for the plot. (Default: 1.5)
base font size, given in pts.
base size for line elements
Size of outline of shapes. (Default: base_size/22)
Breaks for the x axis. Passed to ggplots::scale_x_continuous. (Default: NULL)
Breaks for the y axis. Passed to ggplots::scale_y_continuous. (Default: NULL)
Label for x-axis. (Default: "Risk factor")
Label for y-axis. (Default: "Estimate (95% CI)")
The name of the colour scale/legend for groups. (Default: "")
Position of the legend for groups ("none", "left", "right", "bottom", "top", or two-element numeric vector). (Default: "top")
Plot title. (Default: "Figure")
Print the plot. (Default: TRUE)
Show the ggplot2 code to generate the plot in RStudio 'Viewer' pane. (Default: TRUE)
A character vector of code to add to the generated code. The first element should be a regular expression. The remaining elements are added to the generated code just before the first match of a line (trimmed of whitespace) with the regular expression. (Default: NULL)
Specify additional aesthetics for some ggplot layers.
Specify additional arguments for some ggplot layers.
Environment in which to evaluate the plot code. May be useful when calling this function inside another function.
A list:
the plot
ggplot2 code to generate the plot