Learn R Programming

NetworkInference (version 1.2.5)

plot.cascade: Plot a cascade object

Description

Allows plotting of one or multiple, labeled or unlabeled cascades.

Usage

# S3 method for cascade
plot(x, label_nodes = TRUE, selection = NULL, ...)

Value

A ggplot plot object.

Arguments

x

object of class cascade to be plotted.

label_nodes

logical, indicating if should the nodes in each cascade be labeled. If the cascades are very dense setting this to FALSE is recommended.

selection

a vector of cascade ids to plot.

...

additional arguments passed to plot.

Details

The function returns a ggplot plot object (class gg, ggplot) which can be modified like any other ggplot. See the ggplot documentation and the examples below for more details.

Examples

Run this code

data(cascades)
plot(cascades, selection = names(cascades$cascade_nodes)[1:5])
plot(cascades, label_nodes = FALSE, selection = sample(1:54, 20))

# Modify resulting ggplot object
library(ggplot2) 
p <- plot(cascades, label_nodes = FALSE, selection = sample(1:54, 20))
## Add a title
p <- p + ggtitle('Your Title')
p
## Change Axis
p <- p + xlab("Your modified y axis label") #x and y labels are flipped here
p <- p + ylab("Your modified x axis label") #x and y labels are flipped here
p

Run the code above in your browser using DataLab