Learn R Programming

fdp (version 1.0.0)

+.fdp_plot: Combine fdp plots

Description

Allows combining multiple fdp() plot objects using the + operator.

Usage

# S3 method for fdp_plot
+(e1, e2)

Value

If e2 is an fdp_plot, returns a new combined fdp_plot object. If e2 is a ggplot2 layer, returns a modified ggplot2 object.

Arguments

e1

An fdp_plot object (the result of calling fdp())

e2

Either another fdp_plot object or a ggplot2 layer

Examples

Run this code
# Combine two separate fdp() calls
fdp(gdp(0.5)) + fdp(lap(1))

# Can still add regular ggplot2 layers
fdp(gdp(1)) + ggplot2::ggtitle("My Privacy Plot")

# First legend naming takes precedence
fdp(gdp(0.5), .legend = "First") + fdp(lap(1), .legend = "Second")
# Later .legend arguments apply if none specified in prior calls
fdp(gdp(0.5)) + fdp(lap(1), .legend = "Second")

Run the code above in your browser using DataLab