ggplotbg: Mimic ggplot2 Background

View source: R/utils.R

ggplotbgR Documentation

Mimic ggplot2 Background

Description

Get an imitation ggplot2-style background for plots made outside ggplot2

Usage

ggplotbg(
  bg = transp("lightgray", 0.5),
  x.ax = FALSE,
  y.ax = FALSE,
  box = TRUE,
  grid = TRUE,
  grid.col = "white",
  grid.nx = NULL,
  grid.ny = NULL,
  grid.lwd = 1,
  grid.lty = 1
)

Arguments

bg

The background colour, by default “lightgray” with 50% transparency.

x.ax

A logical specifying whether to re-draw the x-axis.

y.ax

A logical specifying whether to re-draw the y-axis.

box

A logical specifying whether to draw a box around the plotting area.

grid

A logical specifying whether to draw a grid across the background within the plotting area.

grid.col

The color of the gridlines, “white” by default. Only used if grid is set to TRUE.

grid.nx

An optional integer to specify the number of gridlines to be drawn along the x-axis.

grid.ny

An optional integer to specify the number of gridlines to be drawn along the y-axis.

grid.lwd

An integer specifying the lwd (line weight) of the gridlines; by default, set to 1.

grid.lty

An integer specifying the line type to be used for the gridlines; by default, set to 1 (i.e., solid lines).

Details

This function must be sandwiched between two instances of the function used to generate the (foreground) plot to which you are hoping to add this background. Before running the ggplot.bg function, you need to run your plot function so that ggplot.bg knnows how to set the axes. After running the ggplot.bg function, you need to run your plot function again with the added argument add=TRUE so that your plot can be overlayed on top of the background.

Author(s)

Caitlin Collins caitiecollins@gmail.com


caitiecollins/treeWAS documentation built on Sept. 9, 2024, 8:23 a.m.