Plot types: Basic 2D
- Set with
plot_ly(..., type = "scatter")
(overview)
- 2D types:
scatter, bar, box, heatmap, histogram, histogram2d, area, pie, contour
## Warning: Specifying width/height in layout() is now deprecated.
## Please specify in ggplotly() or plot_ly()
d <- data.frame(x = c("SPD", "CDU", "Green"), y = c(40, 25, 37))
plot_ly(data = d, x = ~x, y = ~y, type = "bar") %>%
layout(title = "Barplot",
autosize = F, width = 300, height = 300,
xaxis = list(title= "Voters"),
yaxis = list(title= "N"))
## Warning: Specifying width/height in layout() is now deprecated.
## Please specify in ggplotly() or plot_ly()
## Warning: Specifying width/height in layout() is now deprecated.
## Please specify in ggplotly() or plot_ly()
## Warning: Specifying width/height in layout() is now deprecated.
## Please specify in ggplotly() or plot_ly()
## Warning: Specifying width/height in layout() is now deprecated.
## Please specify in ggplotly() or plot_ly()
d <- data.frame(labels = c("SPD", "CDU", "Green"), values = c(40, 25, 37))
ax <- list(
title = "",
zeroline = FALSE,
showline = FALSE,
showticklabels = FALSE,
showgrid = FALSE
)
plot_ly(d, labels = d$labels, values = d$values, type = "pie") %>%
layout(title = "Pie Chart") %>%
layout(autosize = F, width = 300, height = 300, xaxis = ax, yaxis = ax)
## Warning: Specifying width/height in layout() is now deprecated.
## Please specify in ggplotly() or plot_ly()
## Warning: Specifying width/height in layout() is now deprecated.
## Please specify in ggplotly() or plot_ly()