add_annotations {plotly}R Documentation

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).

...

these arguments are documented at https://github.com/plotly/plotly.js/blob/master/src/components/annotations/attributes.js

data

a data frame.

inherit

inherit attributes from plot_ly()?

Author(s)

Carson Sievert

Examples


# 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) 
  

[Package plotly version 4.7.1 Index]