plotly (version 4.7.1)

add_annotations: Add an annotation(s) to a plot

Description

Add an annotation(s) to a plot

Usage

add_annotations(p, text = NULL, ..., data = NULL, inherit = TRUE)

Arguments

p

a plotly object

text

annotation text (required).

data

a data frame.

inherit

inherit attributes from plot_ly()?

Examples

Run this code
# NOT RUN {
# single annotation
plot_ly(mtcars, x = ~wt, y = ~mpg) %>%
  slice(which.max(mpg)) %>%
  add_annotations(text = "Good mileage")
  
# multiple annotations
plot_ly(mtcars, x = ~wt, y = ~mpg) %>%
  filter(gear == 5) %>%
  add_annotations("five cylinder", ax = 40) 
  
# }

Run the code above in your browser using DataCamp Workspace