Create Various Types of Plots
sp.Rd
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
aes()
function. This includes specifying x, y, and group attributes if needed.- type
Character string specifying the type of plot to create. Accepted values are
points
(for scatter plots),line
(for line charts),bar
(for bar charts),histogram
,density
,pie
, andboxplot
.- mode
Specifies the mode for bar plots. Accepted values are
grouped
,stacked
, andpercent
, determining how bars are arranged. Default isgrouped
.- 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