stat_3D | R Documentation |
This function adds 3D geoms such as points and paths to a ggplot2 plot.
stat_3D(
mapping = NULL,
data = NULL,
geom = "point",
position = "identity",
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE,
...
)
mapping |
Default list of aesthetic mappings to use for plot. If not specified, must be supplied in each layer added to the plot. |
data |
Default dataset to use for plot. If not already a data.frame,
will be converted to one by |
geom |
The geometric object to use to display the data for this layer.
When using a
|
position |
Set position information. Find more details in |
na.rm |
Boolean if na data should be removed. |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If FALSE, overrides the default aesthetics, rather than combining with them. This is most useful for helper functions that define both data and aesthetics and shouldn't inherit behaviour from the default plot specification. |
... |
Arguments passed on to layer. Often the aesthetics
like |
No direct return value, called to be used with ggplot2::ggplot()
in designing the plot.
Acker D (2024). gg3D: 3D perspective plots for ggplot2. R package version 0.0.0.9000.
dat <- electricity
data_lines <- cbind(data.frame("Time" = dat$fparam), dat$data) %>%
tidyr::pivot_longer(cols = 1 + 1:ncol(dat$data))
colors_plot <- RColorBrewer::brewer.pal(11, "Spectral")
colors_plot <- grDevices::colorRampPalette(colors_plot)(ncol(dat$data))
data_lines$color <- rep(colors_plot, nrow(dat$data))
data_lines$name <- as.numeric(data_lines$name)
result <- ggplot2::ggplot(
data_lines,
ggplot2::aes(y = Time, x = name, z = value, color = color)
) +
ggplot2::theme_void() +
stat_3D(theta = 0, phi = 15, geom = "path") +
ggplot2::scale_color_manual(
breaks = data_lines$color,
values = data_lines$color
) +
ggplot2::guides(color = "none")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.