add_labs: Add x, y labels, title, subtitle and caption to a plot.

View source: R/add_labs.R

add_labsR Documentation

Add x, y labels, title, subtitle and caption to a plot.

Description

add_labs takes a ggplot object as input and adds to it user-supplied x, y labels, plot title, subtitle and caption. If user doesn't provide values to these parameters, it'll just use the values from the input plot without making changes.

Usage

add_labs(p, xlab, ylab, title, subtitle, caption)

Arguments

p

A ggplot object.

xlab

String, the x-axis label.

ylab

String, the y-axis label.

title

String, title of the plot. You should use the title to concisely state the main insight the plot reveals. Avoid using generic statement as plot title. For example, "Income vs. Employment Length" is a bad title because it just re-state what the y and x axes are.

subtitle

String, subtitle of the plot. You can use the subtitle to explain the details of the insight. You can even write one or more short paragraphs if you have to.

caption

String, caption of the plot. You can put anything else useful in caption. For example, data source, method referece, url and etc.

Value

A ggplot object annotated with xy labels, title, subtitle and caption.

Examples

inst/examples/ex-add_labs.R

gmlang/ezplot documentation built on Sept. 18, 2022, 6:33 a.m.