sp {SveltePlots} | R Documentation |
Create Various Types of Plots
Description
This function allows for the creation of various types of plots including scatter plots, time-series plots, line charts, bar charts, density plots, histograms, pie charts, and boxplots. It provides flexibility through several arguments that control the appearance and behavior of the plots. The function is part of the SveltePlots package which leverages the power of Svelte and D3 for rendering.
Usage
sp(
data,
mapping,
type,
mode = "grouped",
size = 2,
alpha = 1,
tooltip = TRUE,
include_legend = TRUE,
colors = NULL,
height = 500,
combine_same_groups = TRUE,
breaks = "Sturges",
facet_var = NULL
)
Arguments
data |
A data frame containing the data to be plotted. |
mapping |
A list specifying the mapping of data to aesthetics, similar to ggplot2's |
type |
Character string specifying the type of plot to create. Accepted values are |
mode |
Specifies the mode for bar plots. Accepted values are |
size |
Numeric value specifying the size of the points or lines. |
alpha |
Numeric value specifying the opacity of the points or lines, on a scale from 0 to 1. |
tooltip |
Logical indicating whether tooltips should be shown on hover. |
include_legend |
Logical indicating whether a legend should be included in the plot. |
colors |
A vector of colors to be used for the different groups in the plot. If NULL, default colors are used. |
height |
Numeric value specifying the height of the plot in pixels. |
combine_same_groups |
Logical indicating whether multiple series with the same group should be combined into one legend category. |
breaks |
Controls the number of bins for histograms. Can be a vector or a method compatible with the hist() function's breaks argument. |
facet_var |
A character vector splitting the data for faceting charts |
Value
A SveltePlots plot object which can be rendered in a web page or an R Markdown document.
Examples
library(SveltePlots)
data("penguins")
sp(
data = penguins,
mapping = spaes(x = flipper_length_mm, y = bill_length_mm, group = species),
type = "points"
)