add_trace

0th

Percentile

Add trace(s) to a plotly visualization

Add trace(s) to a plotly visualization

Usage
add_trace(p, ..., data = NULL, inherit = TRUE)

add_markers(p, x = NULL, y = NULL, z = NULL, ..., data = NULL, inherit = TRUE)

add_text(p, x = NULL, y = NULL, z = NULL, text = NULL, ..., data = NULL, inherit = TRUE)

add_paths(p, x = NULL, y = NULL, z = NULL, ..., data = NULL, inherit = TRUE)

add_lines(p, x = NULL, y = NULL, z = NULL, ..., data = NULL, inherit = TRUE)

add_segments(p, x = NULL, y = NULL, xend = NULL, yend = NULL, ..., data = NULL, inherit = TRUE)

add_polygons(p, x = NULL, y = NULL, ..., data = NULL, inherit = TRUE)

add_ribbons(p, x = NULL, ymin = NULL, ymax = NULL, ..., data = NULL, inherit = TRUE)

add_area(p, r = NULL, t = NULL, ..., data = NULL, inherit = TRUE)

add_pie(p, values = NULL, labels = NULL, ..., data = NULL, inherit = TRUE)

add_bars(p, x = NULL, y = NULL, ..., data = NULL, inherit = TRUE)

add_histogram(p, x = NULL, y = NULL, ..., data = NULL, inherit = TRUE)

add_histogram2d(p, x = NULL, y = NULL, z = NULL, ..., data = NULL, inherit = TRUE)

add_histogram2dcontour(p, x = NULL, y = NULL, z = NULL, ..., data = NULL, inherit = TRUE)

add_heatmap(p, x = NULL, y = NULL, z = NULL, ..., data = NULL, inherit = TRUE)

add_contour(p, z = NULL, ..., data = NULL, inherit = TRUE)

add_boxplot(p, x = NULL, y = NULL, ..., data = NULL, inherit = TRUE)

add_surface(p, z = NULL, ..., data = NULL, inherit = TRUE)

add_mesh(p, x = NULL, y = NULL, z = NULL, ..., data = NULL, inherit = TRUE)

add_scattergeo(p, ...)

add_choropleth(p, z = NULL, ..., data = NULL, inherit = TRUE)

Arguments
p

a plotly object

...

These arguments are documented at https://plot.ly/r/reference/ Note that acceptable arguments depend on the value of type.

data

A data frame (optional).

inherit

inherit attributes from plot_ly()?

x

the x variable.

y

the y variable.

z

a numeric matrix

text

textual labels.

xend

"final" x position (in this context, x represents "start")

yend

"final" y position (in this context, y represents "start")

ymin

a variable used to define the lower boundary of a polygon.

ymax

a variable used to define the upper boundary of a polygon.

r

For polar chart only. Sets the radial coordinates.

t

For polar chart only. Sets the radial coordinates.

values

the value to associated with each slice of the pie.

labels

the labels (categories) corresponding to values.

References

https://plot.ly/r/reference/

See Also

plot_ly()

Aliases
  • add_area
  • add_bars
  • add_boxplot
  • add_choropleth
  • add_contour
  • add_heatmap
  • add_histogram
  • add_histogram2d
  • add_histogram2dcontour
  • add_lines
  • add_markers
  • add_mesh
  • add_paths
  • add_pie
  • add_polygons
  • add_ribbons
  • add_scattergeo
  • add_segments
  • add_surface
  • add_text
  • add_trace
Examples
library(plotly) # NOT RUN { p <- plot_ly(economics, x = ~date, y = ~uempmed) p p %>% add_markers() p %>% add_lines() p %>% add_text(text = ".") # attributes declared in plot_ly() carry over to downstream traces, # but can be overwritten plot_ly(economics, x = ~date, y = ~uempmed, color = I("red")) %>% add_lines() %>% add_markers(color = ~pop) %>% layout(showlegend = FALSE) txhousing %>% group_by(city) %>% plot_ly(x = ~date, y = ~median) %>% add_lines(fill = "black") ggplot2::map_data("world", "canada") %>% group_by(group) %>% plot_ly(x = ~long, y = ~lat) %>% add_polygons(hoverinfo = "none") %>% add_markers(text = ~paste(name, "<br />", pop), hoverinfo = "text", data = maps::canada.cities) %>% layout(showlegend = FALSE) plot_ly(economics, x = ~date) %>% add_ribbons(ymin = ~pce - 1e3, ymax = ~pce + 1e3) p <- plot_ly(plotly::wind, r = ~r, t = ~t) %>% add_area(color = ~nms) layout(p, radialaxis = list(ticksuffix = "%"), orientation = 270) ds <- data.frame( labels = c("A", "B", "C"), values = c(10, 40, 60) ) plot_ly(ds, labels = ~labels, values = ~values) %>% add_pie() %>% layout(title = "Basic Pie Chart using Plotly") library(dplyr) mtcars %>% count(vs) %>% plot_ly(x = ~vs, y = ~n) %>% add_bars() plot_ly(x = ~rnorm(100)) %>% add_histogram() plot_ly(x = ~LETTERS, y = ~LETTERS) %>% add_histogram2d() z <- as.matrix(table(LETTERS, LETTERS)) plot_ly(x = ~LETTERS, y = ~LETTERS, z = ~z) %>% add_histogram2d() plot_ly(MASS::geyser, x = ~waiting, y = ~duration) %>% add_histogram2dcontour() plot_ly(z = ~volcano) %>% add_heatmap() plot_ly(z = ~volcano) %>% add_contour() plot_ly(mtcars, x = ~factor(vs), y = ~mpg) %>% add_boxplot() plot_ly(z = ~volcano) %>% add_surface() plot_ly(x = c(0, 0, 1), y = c(0, 1, 0), z = c(0, 0, 0)) %>% add_mesh() # }
Documentation reproduced from package plotly, version 4.5.2, License: MIT + file LICENSE

Community examples

Looks like there are no examples yet.