library(plotly)
## Loading required package: ggplot2
## Warning: package 'ggplot2' was built under R version 3.3.2
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
### arrows using plot_ly() ###
arrow1 = list(
  # main line
  list(
    line = list(
      color = "rgba(31, 119, 180, 100)", 
      width = 3
    ), 
    type = "line", 
    x0 = 0.6, 
    x1 = 0.8, 
    xref = "paper", 
    y0 = 0.5, 
    y1 = 0.5, 
    yref = "paper"
  ), 
  # arrow head
  list(
    line = list(
      color = "rgba(31, 119, 180, 100)", 
      width = 3
    ), 
    type = "line", 
    x0 = 0.8, 
    x1 = 0.78, 
    xref = "paper", 
    y0 = 0.5, 
    y1 = 0.52, 
    yref = "paper"
  ), 
  # arrow head
  list(
    line = list(
      color = "rgba(31, 119, 180, 100)", 
      width = 3
    ), 
    type = "line", 
    x0 = 0.8, 
    x1 = 0.78, 
    xref = "paper", 
    y0 = 0.5, 
    y1 = 0.48, 
    yref = "paper"
  )
)


# Intialise blank plot, add annotation arrow, add shapes
p <- plot_ly() %>%
  add_annotations(x = 1,
                  y = 1,
                  text = "This is an annotation arrow",
                  xref = "x",
                  yref = "y",
                  showarrow = TRUE,
                  arrowhead = 4,
                  arrowsize = .5,
                  ax = 20,
                  ay = -40) %>%
  layout(shapes = arrow1)