Skip to contents

Standard convert ggplot to plotly object

Usage

as_plotly(
  plot,
  height = NULL,
  width = NULL,
  legend_opts = list(label = "", pos = "bottom", dir = "h"),
  axis_opts = list(xopts = list(showticklabels = TRUE, showline = TRUE, mirror = TRUE),
    yopts = list(showticklabels = TRUE, showline = TRUE, mirror = TRUE)),
  hover = "text"
)

Arguments

plot

Input ggplot object

height

Height of interactive plot

width

Width of interactive plot

legend_opts

Legend styling option, a list containing label, pos(position) and dir (direction).

axis_opts

Axis styling option. Default is a named list list(xopts = list(showticklabels = TRUE, showline = TRUE, mirror = TRUE), yopts = list(showticklabels = TRUE, showline = TRUE, mirror = TRUE)) # nolint

hover

Tooltip aesthetic

Value

plotly widget

Examples

library(ggplot2)

gplot <- adsl[1:100, ] |>
  ggplot(aes(x = .data[["RACE"]], y = .data[["AGE"]], text = .data[["USUBJID"]])) +
  geom_point()
as_plotly(
  plot = gplot,
  height = 400,
  width = 400
)