| Title: | Flexible, Interactive 'shiny' Modules for Almost Any Plot |
|---|---|
| Description: | Offers a core selection of interactivity-first 'shiny' modules for many plot types meant to serve as flexible building blocks for applications and as the base for more complex modules. These modules allow for the rapid and convenient construction of 'shiny' apps with very few lines of code and decouple plotting from the underlying data. These modules allow for full plot aesthetic customization by the end user through UI inputs. Utility functions for simple UI organization, automated UI tooltips, and additional plot enhancements are also provided. |
| Authors: | Jared Andrews [aut, cre] (ORCID: <https://orcid.org/0000-0002-0780-6248>), Jacob Martin [aut] (ORCID: <https://orcid.org/0009-0007-6896-4796>) |
| Maintainer: | Jared Andrews <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.1 |
| Built: | 2026-05-17 09:27:17 UTC |
| Source: | https://github.com/j-andrews7/vizmodules |
Applies a named mathematical transformation to a specified numeric column in a data frame,
adding the transformed values as a new column (original column name + ".adj").
The transformation name must be one of the allowed functions listed in safe_resolve_adj_fxn
(e.g., "log2", "log10", "sqrt", "abs", "as.factor"). The original data frame is returned unchanged
if no transformation is specified or if the supplied name is invalid.
adjust_column_values( df, x.col = NULL, y.col = NULL, color.col = NULL, x.adj.fun = NULL, y.adj.fun = NULL, color.adj.fun = NULL )adjust_column_values( df, x.col = NULL, y.col = NULL, color.col = NULL, x.adj.fun = NULL, y.adj.fun = NULL, color.adj.fun = NULL )
df |
A data frame containing the column to be transformed. |
x.col |
Character scalar. Name of the column for x‑axis values (optional). |
y.col |
Character scalar. Name of the column for y‑axis values (optional). |
color.col |
Character scalar. Name of the column for color values (optional). |
x.adj.fun |
Character scalar. Name of a transformation function to apply to x‑axis values,
as accepted by |
y.adj.fun |
Character scalar. Name of a transformation function to apply to y‑axis values,
as accepted by |
color.adj.fun |
Character scalar. Name of a transformation function to apply to color values,
as accepted by |
A data frame identical to input df but with transformed columns added
(e.g., mpg.adj) when valid transformations are specified.
Jacob Martin, Jared Andrews
data(mtcars) mtcars_mod <- adjust_column_values(mtcars, x.col = "mpg", x.adj.fun = "log2") head(mtcars_mod$mpg.adj)data(mtcars) mtcars_mod <- adjust_column_values(mtcars, x.col = "mpg", x.adj.fun = "log2") head(mtcars_mod$mpg.adj)
Factory function that generates a standard Shiny application for any VizModules module. The resulting app features a Data Import section for uploading data files, a Data Table for viewing and editing the active dataset, and a Plot area for configuring and displaying an interactive plot.
createModuleApp( inputs_ui_fn, output_ui_fn, server_fn, data_list, title = "VizModules App" )createModuleApp( inputs_ui_fn, output_ui_fn, server_fn, data_list, title = "VizModules App" )
inputs_ui_fn |
A function with signature
|
output_ui_fn |
A function with signature |
server_fn |
A function with signature
|
data_list |
A named list of data frames. At least one element is required. |
title |
A character string used as the page title
(default: |
Uploaded files (Excel, CSV, TSV, or tab-delimited text) are added to the available datasets and can be selected for plotting. If an uploaded file shares a name with an existing dataset, the existing one is overwritten with a warning.
Every module-specific *App() convenience function (e.g.
plotthis_BarPlotApp(), linePlotApp()) is a thin wrapper around
createModuleApp().
You can also call it directly for quick prototyping or to create apps
for custom wrapper modules.
A shiny::shinyApp() object.
Jared Andrews
library(VizModules) # Quick-launch a bar plot app with custom data: app <- createModuleApp( inputs_ui_fn = plotthis_BarPlotInputsUI, output_ui_fn = plotthis_BarPlotOutputUI, server_fn = plotthis_BarPlotServer, data_list = list("iris" = iris), title = "My Bar Plot" ) if (interactive()) runApp(app) # Works with any module trio, including custom wrapper modules: app2 <- createModuleApp( inputs_ui_fn = dittoViz_scatterPlotInputsUI, output_ui_fn = dittoViz_scatterPlotOutputUI, server_fn = dittoViz_scatterPlotServer, data_list = list("iris" = iris), title = "Scatter" ) if (interactive()) runApp(app2)library(VizModules) # Quick-launch a bar plot app with custom data: app <- createModuleApp( inputs_ui_fn = plotthis_BarPlotInputsUI, output_ui_fn = plotthis_BarPlotOutputUI, server_fn = plotthis_BarPlotServer, data_list = list("iris" = iris), title = "My Bar Plot" ) if (interactive()) runApp(app) # Works with any module trio, including custom wrapper modules: app2 <- createModuleApp( inputs_ui_fn = dittoViz_scatterPlotInputsUI, output_ui_fn = dittoViz_scatterPlotOutputUI, server_fn = dittoViz_scatterPlotServer, data_list = list("iris" = iris), title = "Scatter" ) if (interactive()) runApp(app2)
Renders an interactive DT table with column-level filters and returns a
reactive containing only the currently visible (filtered) rows. This
reactive can be passed directly to any plotting module as its data
argument.
dataFilterServer(id, data, factor.char.cols = TRUE, page.length = 10)dataFilterServer(id, data, factor.char.cols = TRUE, page.length = 10)
id |
The ID for the Shiny module. Must match the |
data |
A |
factor.char.cols |
Logical. When |
page.length |
Integer. The default number of rows shown per page.
Defaults to |
A reactive expression that evaluates to the filtered subset of
data based on the current DT selection/filter state. Pass this
reactive to a plotting module's data argument to keep the plot in
sync with the table filters.
Jacob Martin
library(shiny) library(VizModules) ui <- fluidPage( dataFilterUI("filter"), verbatimTextOutput("rows") ) server <- function(input, output, session) { data <- reactive(iris) filtered <- dataFilterServer("filter", data, factor.char.cols = TRUE) output$rows <- renderPrint(nrow(filtered())) } if (interactive()) shinyApp(ui, server)library(shiny) library(VizModules) ui <- fluidPage( dataFilterUI("filter"), verbatimTextOutput("rows") ) server <- function(input, output, session) { data <- reactive(iris) filtered <- dataFilterServer("filter", data, factor.char.cols = TRUE) output$rows <- renderPrint(nrow(filtered())) } if (interactive()) shinyApp(ui, server)
Renders an interactive DT table that allows users to filter rows of a data
frame. Place this in the UI where you want the filterable table to appear,
using an id that matches the one passed to dataFilterServer().
dataFilterUI(id)dataFilterUI(id)
id |
The ID for the Shiny module. |
A Shiny tagList containing the DT table output.
Jacob Martin
library(VizModules) dataFilterUI("myFilter")library(VizModules) dataFilterUI("myFilter")
Returns a list of predefined color palettes grouped by category (Defaults, Viridis, Diverging, Qualitative, Sequential) for use with color picker UI components.
default_palettes()default_palettes()
A named list with two elements: choices (a nested list of palette
name to color vector mappings, grouped by category) and textColor (a
character vector of text colors for each palette).
Jared Andrews
pals <- default_palettes() names(pals$choices)pals <- default_palettes() names(pals$choices)
This function generates a Shiny application with modular dittoViz::scatterPlot() components.
The app features a Data Import section for uploading data,
a Data Table for filtering the active dataset, and a Plot area
for configuring and displaying an interactive scatter plot.
dittoViz_scatterPlotApp(data_list = NULL)dittoViz_scatterPlotApp(data_list = NULL)
data_list |
An optional named list of data frames. If |
When data_list is not provided (or NULL), the app launches with
gallery_sales as an example dataset. Uploaded data files are added
to the available datasets and can be selected for plotting. If an uploaded
file shares a name with an existing dataset, the existing one is overwritten
with a warning.
This is a convenience wrapper around createModuleApp().
A Shiny app object.
Jared Andrews
dittoViz::scatterPlot(), dittoViz_scatterPlotInputsUI(),
dittoViz_scatterPlotOutputUI(), dittoViz_scatterPlotServer()
library(VizModules) # Launch with default example data: app <- dittoViz_scatterPlotApp() if (interactive()) runApp(app) # Launch with custom data: app2 <- dittoViz_scatterPlotApp(list("sales" = example_sales)) if (interactive()) runApp(app2)library(VizModules) # Launch with default example data: app <- dittoViz_scatterPlotApp() if (interactive()) runApp(app) # Launch with custom data: app2 <- dittoViz_scatterPlotApp(list("sales" = example_sales)) if (interactive()) runApp(app2)
This should be placed in the UI where the inputs should be shown, with an id
that matches the id used in the dittoViz_scatterPlotServer() and dittoViz_scatterPlotOutputUI() functions.
dittoViz_scatterPlotInputsUI( id, data, defaults = NULL, title = NULL, columns = 2 )dittoViz_scatterPlotInputsUI( id, data, defaults = NULL, title = NULL, columns = 2 )
id |
The ID for the Shiny module. |
data |
The data frame used for plot generation. |
defaults |
A named list of default values for the inputs. |
title |
An optional title for the UI grid. |
columns |
Number of columns for the UI grid. |
The user inputs for this module are separated from the outputs to allow for more flexible UI design.
The inputs will automatically be organized into a grid layout via the organize_inputs() function,
with columns controlling the number of columns in the grid.
Defaults can be set for each input by providing a named list of values to the defaults argument.
Nearly all parameters for dittoViz::scatterPlot() can be set via these inputs, so see the help
for that function for an exhaustive list.
Note that some of the parameters may have input types that differ from the actual function, e.g. shape.panel
is a text input for comma-separated integers, while the function expects a vector of integers.
The module will parse such inputs into the appropriate format for dittoViz::scatterPlot() automatically.
A Shiny tagList containing the UI elements
The following dittoViz::scatterPlot() parameters are not available via UI inputs or have been superseded:
xlab - X-axis label (plotly allows interactive editing)
ylab - Y-axis label (plotly allows interactive editing)
main - Plot title (plotly allows interactive editing)
sub - Plot subtitle (not supported in plotly)
theme - ggplot2 theme (not applicable to plotly)
legend.title - Legend title (managed by plotly interactively)
add.xline - Use vline.intercepts instead for vertical lines with full styling options
add.yline - Use hline.intercepts instead for horizontal lines with full styling options
xline.linetype - Use vline.linetypes instead
xline.color - Use vline.colors instead
yline.linetype - Use hline.linetypes instead
yline.color - Use hline.colors instead
do.letter - Lettering subplots (not implemented for plotly)
do.label - Labeling points interactively (not compatible with plotly hover)
The new Lines tab provides enhanced functionality including multiple lines per type, individual line widths, opacities, and diagonal/ablines with slope control.
The following dittoViz::scatterPlot() parameters can be accessed via UI inputs and/or the defaults argument:
x.by - X-axis variable (UI: "X Data", default: 2nd column)
y.by - Y-axis variable (UI: "Y Data", default: 3rd column)
color.by - Coloring variable (UI: "Color By", default: "")
shape.by - Shape variable (UI: "Shape By", default: "")
split.by - Faceting variable (UI: "Split By", default: "")
rows.use - Row filter expression (UI: "Rows Filter", default: "")
x.adjustment - X-axis adjustment (UI: "X Adjustment", default: "")
y.adjustment - Y-axis adjustment (UI: "Y Adjustment", default: "")
color.adjustment - Color adjustment (UI: "Color Adjustment", default: "")
x.adj.fxn - X adjustment function (UI: "X Adjustment Function", default: "")
y.adj.fxn - Y adjustment function (UI: "Y Adjustment Function", default: "")
color.adj.fxn - Color adjustment function (UI: "Color Adjustment Function", default: "")
size - Point size (UI: "Point Size", default: 1)
opacity - Point opacity (UI: "Point Opacity", default: 1)
show.others - Show others (UI: "Show Others", default: TRUE)
split.show.all.others - Show split others (UI: "Show Split Others", default: TRUE)
plot.order - Plot order (UI: "Plot Order", default: "unordered")
shape.panel - Shape panel values (UI: "Shape Panel", default: "16, 15, 17, 23, 25, 8")
min.color - Minimum color (UI: "Min Color", default: "#F0E442")
max.color - Maximum color (UI: "Max Color", default: "#0072B2")
contour.color - Contour color (UI: "Contour Color", default: "black")
contour.linetype - Contour linetype (UI: "Contour Linetype", default: "solid")
color.panel - Custom color values (UI: color.panel.ui, derived from palette)
split.nrow - Number of split rows (UI: "Split Rows", default: NA)
split.ncol - Number of split columns (UI: "Split Columns", default: NA)
multivar.split.dir - Multivar split direction (UI: "Multivar Split Dir", default: "col")
split.adjust.scales - Facet scales (UI: "Facet Scales", default: "fixed")
annotate.by - Annotate by column (UI: "Annotate By", default: "")
highlight.points - Points to highlight (UI: "Points to Highlight", default: "")
highlight.color - Highlight fill (UI: "Highlight Fill", default: "#00FFF7")
highlight.size - Highlight size (UI: "Highlight Size", default: 7)
highlight.border.color - Highlight border color (UI: "Highlight Border Color", default: "#000000")
highlight.border.width - Highlight border width (UI: "Highlight Border Width", default: 1)
highlight.auto.annotate - Auto-annotate highlights (UI: "Auto-annotate Highlights", default: TRUE)
annotation.color - Annotation color (UI: "Annotation Color", default: "black")
annotation.ax - Annotation X offset (UI: "Annotation X Offset", default: 20)
annotation.ay - Annotation Y offset (UI: "Annotation Y Offset", default: -20)
annotation.size - Annotation size (UI: "Annotation Size", default: 10)
annotation.showarrow - Show arrow (UI: "Show Arrow", default: TRUE)
annotation.arrowcolor - Arrow color (UI: "Arrow Color", default: "black")
annotation.arrowhead - Arrowhead style (UI: "Arrowhead Style", default: 2)
annotation.arrowwidth - Arrow linewidth (UI: "Arrow Linewidth", default: 1.5)
legend.show - Show legend (UI: "Show Legend", default: TRUE)
legend.color.title - Legend title (UI: "Legend Title", default: "make")
legend.color.size - Legend color size (UI: "Legend Color Size", default: 5)
legend.shape.size - Legend shape size (UI: "Legend Shape Size", default: 5)
legend.color.breaks - Legend tick breaks (UI: "Legend Tick Breaks", default: "")
min.value - Minimum value (UI: "Min Value", default: NA)
max.value - Maximum value (UI: "Max Value", default: NA)
trajectory.group.by - Trajectory group by (UI: "Trajectory Group By", default: "")
add.trajectory.by.groups - Add trajectory by groups (UI: "Add Trajectory By Groups", default: "")
trajectory.arrow.size - Trajectory arrow size (UI: "Trajectory Arrow Size", default: 0.15)
do.ellipse - Enable ellipses (UI: "Enable Ellipses", default: FALSE)
do.contour - Enable contour (UI: "Enable Contour", default: FALSE)
hover.data - Hover data columns (UI: "Hover Data", default: "")
hover.round.digits - Hover round digits (UI: "Hover Round Digits", default: 5)
The following parameters implementing new functionality or controlling plotly-specific features are also available:
webgl - Plot with webGL (UI: "Plot with webGL", default: TRUE)
shape.fill - Shape fill color (UI: "Shape Fill", default: "rgba(0, 0, 0, 0)")
shape.line.color - Shape line color (UI: "Shape Line Color", default: "black")
shape.line.width - Shape line width (UI: "Shape Line Width", default: 4)
shape.linetype - Shape linetype (UI: "Shape Linetype", default: "solid")
shape.opacity - Shape opacity (UI: "Shape Opacity", default: 1)
title.font.size - Plot title font size (UI: "Title Size", default: 26)
title.font.family - Font family for title text (UI: "Title Font", default: "Arial")
title.font.color - Color for plot title (UI: "Title Color", default: "#000000")
axis.title.font.size - Axis title font size (UI: "Axis Title Size", default: 18)
axis.title.font.color - Axis title font color (UI: "Axis Title Color", default: "#000000")
axis.title.font.family - Axis title font family (UI: "Axis Title Font", default: "Arial")
axis.showline - Show axis border lines (UI: "Show Axis Borders", default: TRUE)
axis.mirror - Mirror axis lines on opposite side (UI: "Mirror Axis Borders", default: TRUE)
show.grid.x - Show X-axis major gridlines (UI: "Show X Gridlines", default: TRUE)
show.grid.y - Show Y-axis major gridlines (UI: "Show Y Gridlines", default: TRUE)
grid.color - Gridline color (UI: "Gridline Color", default: "#CCCCCC")
axis.linecolor - Color of axis lines (UI: "Axis Line Color", default: "black")
axis.linewidth - Width of axis lines (UI: "Axis Line Width", default: 0.5)
axis.tickfont.size - Size of tick labels (UI: "Tick Label Size", default: 12)
axis.tickfont.color - Color of tick labels (UI: "Tick Label Color", default: "black")
axis.tickfont.family - Font family for tick labels (UI: "Tick Label Font", default: "Arial")
axis.tickangle.x - Rotation angle for X-axis tick labels (UI: "X Tick Label Angle", default: 0)
axis.tickangle.y - Rotation angle for Y-axis tick labels (UI: "Y Tick Label Angle", default: 0)
axis.ticks - Position of tick marks (UI: "Tick Position", default: "outside")
axis.tickcolor - Color of tick marks (UI: "Tick Mark Color", default: "black")
axis.ticklen - Length of tick marks (UI: "Tick Mark Length", default: 5)
axis.tickwidth - Width of tick marks (UI: "Tick Mark Width", default: 1)
facet.title.font.size - Facet subplot title font size (UI: "Facet Subplot Title Size", default: 18)
facet.title.font.color - Facet subplot title font color (UI: "Facet Title Color", default: "#000000")
facet.title.font.family - Facet subplot title font family (UI: "Facet Title Font", default: "Arial")
hline.intercepts - Y-coordinates for horizontal reference lines (UI: "Y-intercepts", default: "")
hline.colors - Colors for horizontal lines (UI: "Colors", default: "#000000")
hline.widths - Widths for horizontal lines (UI: "Widths", default: "1")
hline.linetypes - Line types for horizontal lines (UI: "Line Types", default: "dashed")
hline.opacities - Opacities for horizontal lines (UI: "Opacities (0-1)", default: "1")
vline.intercepts - X-coordinates for vertical reference lines (UI: "X-intercepts", default: "")
vline.colors - Colors for vertical lines (UI: "Colors", default: "#000000")
vline.widths - Widths for vertical lines (UI: "Widths", default: "1")
vline.linetypes - Line types for vertical lines (UI: "Line Types", default: "dashed")
vline.opacities - Opacities for vertical lines (UI: "Opacities (0-1)", default: "1")
abline.slopes - Slopes for diagonal reference lines (UI: "Slopes", default: "")
best.fit - Enable line of best fit (UI: "Line of best fit:", default: FALSE)
line.best.smoothness - Smoothness of line of best fit (UI: "Smoothness of line of best fit:", default: 1)
line.best.colour - Color of line of best fit (UI: "Line of best fit colour:", default: "#000000")
linear.model - Enable linear model line (UI: "Linear model line", default: FALSE)
Jared Andrews
dittoViz::scatterPlot(), organize_inputs(),
dittoViz_scatterPlotOutputUI(), dittoViz_scatterPlotServer(), dittoViz_scatterPlotApp()
library(VizModules) dittoViz_scatterPlotInputsUI("scatterPlot", example_mtcars)library(VizModules) dittoViz_scatterPlotInputsUI("scatterPlot", example_mtcars)
This should be placed in the UI where the plot should be shown.
dittoViz_scatterPlotOutputUI(id)dittoViz_scatterPlotOutputUI(id)
id |
The ID for the Shiny module. |
A Shiny plotlyOutput for the scatterplot
Jared Andrews
Server logic for scatterPlot module
dittoViz_scatterPlotServer( id, data, hide.inputs = NULL, hide.tabs = NULL, manual.colors = NULL, defaults = NULL )dittoViz_scatterPlotServer( id, data, hide.inputs = NULL, hide.tabs = NULL, manual.colors = NULL, defaults = NULL )
id |
The ID for the Shiny module. |
data |
A |
hide.inputs |
A character vector of input IDs to hide. These will still be initialized and their values passed to the plot function, but the user will not be able to see/adjust them in the UI. |
hide.tabs |
A character vector of tab names to hide. Inputs in these tabs will still be initialized and their values passed to the plot function, but the user will not be able to see/adjust them in the UI. |
manual.colors |
A named character vector of colors or a reactive returning a named character vector of colors. |
defaults |
A named list of default values for the inputs. When the reset button is clicked, inputs are reset to these values rather than hardcoded fallbacks. Typically the same list passed to the corresponding UI function. |
The moduleServer function for the scatterPlot module.
Jared Andrews
dittoViz::scatterPlot(), dittoViz_scatterPlotInputsUI(),
dittoViz_scatterPlotOutputUI(), dittoViz_scatterPlotApp()
This function generates a Shiny application with modular dittoViz::yPlot() components.
The app features a Data Import section for uploading data,
a Data Table for filtering the active dataset, and a Plot area
for configuring and displaying an interactive y plot.
dittoViz_yPlotApp(data_list = NULL)dittoViz_yPlotApp(data_list = NULL)
data_list |
An optional named list of data frames. If |
When data_list is not provided (or NULL), the app launches with
gallery_demographics as an example dataset. Uploaded data files are added
to the available datasets and can be selected for plotting. If an uploaded
file shares a name with an existing dataset, the existing one is overwritten
with a warning.
This is a convenience wrapper around createModuleApp().
A Shiny app object.
Jared Andrews
dittoViz::yPlot(), dittoViz_yPlotInputsUI(),
dittoViz_yPlotOutputUI(), dittoViz_yPlotServer()
library(VizModules) # Launch with default example data: app <- dittoViz_yPlotApp() if (interactive()) runApp(app) # Launch with custom data: app2 <- dittoViz_yPlotApp(list("demographics" = example_demographics)) if (interactive()) runApp(app2)library(VizModules) # Launch with default example data: app <- dittoViz_yPlotApp() if (interactive()) runApp(app) # Launch with custom data: app2 <- dittoViz_yPlotApp(list("demographics" = example_demographics)) if (interactive()) runApp(app2)
This should be placed in the UI where the inputs should be shown, with an id
that matches the id used in the dittoViz_yPlotServer() and dittoViz_yPlotOutputUI() functions.
dittoViz_yPlotInputsUI(id, data, defaults = NULL, title = NULL, columns = 2)dittoViz_yPlotInputsUI(id, data, defaults = NULL, title = NULL, columns = 2)
id |
The ID for the Shiny module. |
data |
The data frame used for plot generation. |
defaults |
A named list of default values for the inputs. |
title |
An optional title for the UI grid. |
columns |
Number of columns for the UI grid. |
The user inputs for this module are separated from the outputs to allow for more flexible UI design.
The inputs will automatically be organized into a grid layout via the organize_inputs() function,
with columns controlling the number of columns in the grid.
Defaults can be set for each input by providing a named list of values to the defaults argument.
Nearly all parameters for dittoViz::yPlot() can be set via these inputs, so see the help
for that function for an exhaustive list.
A Shiny tagList containing the UI elements
The following dittoViz::yPlot() parameters are not available via UI inputs:
xlab - X-axis label (plotly allows interactive editing)
ylab - Y-axis label (plotly allows interactive editing)
main - Plot title (plotly allows interactive editing)
sub - Plot subtitle (not supported in plotly)
theme - ggplot2 theme (not applicable to plotly)
legend.title - Legend title (managed by plotly interactively)
add.line - Use hline.intercepts instead for horizontal lines with full styling options
line.linetype - Use hline.linetypes instead
line.color - Use hline.colors instead
The following dittoViz::yPlot() parameters can be accessed via UI inputs and/or the defaults argument:
var - Y-axis variable (UI: "Y data (var)", default: 2nd numeric variable)
group.by - Grouping variable for x-axis (UI: "Group by", default: 2nd categorical variable)
color.by - Coloring variable (UI: "Color by", default: "")
shape.by - Shape variable (UI: "Shape by", default: "")
split.by - Faceting variable (UI: "Split by (facet)", default: "")
plots - Plot types to show (UI: "Plots to show", default: c("boxplot", "jitter"))
color.panel - Custom color values (UI: palette picker, derived from palette)
min - Y-axis minimum (UI: "Y Axis Min", auto-calculated)
max - Y-axis maximum (UI: "Y Axis Max", auto-calculated)
split.nrow - Number of facet rows (UI: "Number of Rows", default: 4)
split.ncol - Number of facet columns (UI: "Number of Columns", default: 4)
split.adjust - Facet scale behavior (UI: "Facet Scaling", default: "free")
do.raster - Rasterize jitter points (UI: "Rasterize Jitter", default: FALSE)
raster.dpi - DPI for rasterization (UI: "Raster DPI", default: 600)
jitter.size - Jitter point size (UI: "Jitter Point Size", default: 1)
jitter.width - Jitter width (UI: "Jitter Width", default: 0.2)
jitter.color - Jitter point color (UI: "Jitter Point Color", default: "#000000")
jitter.shape.legend.size - Shape legend size (UI: "Shape Legend Size", default: 5)
jitter.shape.legend.show - Show shape legend (UI: "Show Shape Legend", default: TRUE)
jitter.position.dodge - Jitter position dodge (calculated from boxgap)
boxplot.show.outliers - Show boxplot outliers
boxplot.color - Boxplot outline color (UI: "Boxplot Color", default: "#000000")
boxplot.fill - Fill boxplot (UI: "Fill Boxplot", default: TRUE)
boxplot.lineweight - Boxplot line weight (UI: "Boxplot Line Weight", default: 0.5)
vlnplot.lineweight - Violin line weight (UI: "Violin Line Weight", default: 0.5)
vlnplot.scaling - Violin scaling method (UI: "Violin Scaling", default: "area")
vlnplot.quantiles - Violin quantiles (UI: "Violin Quantiles (0-1)", default: "")
vlnplot.width - Violin width (derived from boxgap; not directly settable)
ridgeplot.lineweight - Ridge line weight (UI: "Ridge Line Weight", default: 0.5)
ridgeplot.scale - Ridge overlap scale (UI: "Ridge Scale (overlap)", default: 1.25)
ridgeplot.ymax.expansion - Ridge Y-max expansion (UI: "Ridge Y-max Expansion", default: NA)
ridgeplot.shape - Ridge shape (UI: "Ridge Shape", default: "smooth")
ridgeplot.bins - Ridge bins (UI: "Ridge Bins", default: 30)
ridgeplot.binwidth - Ridge binwidth (UI: "Ridge Binwidth", default: NULL)
legend.show - Show legend (always TRUE; not directly settable)
The following parameters implementing new functionality or controlling plotly-specific features are also available:
boxmode - Boxplot mode grouping (calculated: "group" or "overlay" based on color.by)
boxgap - Boxplot position dodge (UI: "Boxplot Position Dodge", default: 0.3)
boxgroupgap - Boxplot group dodge (UI: "Boxplot Group Dodge", default: 0.2)
title.font.size - Plot title font size (UI: "Title Size", default: 26)
title.font.family - Font family for title text (UI: "Title Font", default: "Arial")
title.font.color - Color for plot title (UI: "Title Color", default: "#000000")
axis.title.font.size - Axis title font size (UI: "Axis Title Size", default: 18)
axis.title.font.color - Axis title font color (UI: "Axis Title Color", default: "#000000")
axis.title.font.family - Axis title font family (UI: "Axis Title Font", default: "Arial")
axis.showline - Show axis border lines (UI: "Show Axis Lines", default: TRUE)
axis.mirror - Mirror axis lines on opposite side (UI: "Mirror Axis Lines", default: TRUE)
show.grid.x - Show X-axis major gridlines (UI: "Show X Major Gridlines", default: TRUE)
show.grid.y - Show Y-axis major gridlines (UI: "Show Y Major Gridlines", default: TRUE)
axis.linecolor - Color of axis lines (UI: "Axis Line Color", default: "black")
axis.linewidth - Width of axis lines (UI: "Axis Line Width", default: 0.5)
axis.tickfont.size - Size of tick labels (UI: "Tick Label Size", default: 12)
axis.tickfont.color - Color of tick labels (UI: "Tick Label Color", default: "black")
axis.tickfont.family - Font family for tick labels (UI: "Tick Label Font", default: "Arial")
axis.tickangle.x - Rotation angle for X-axis tick labels (UI: "X-axis Tick Label Angle", default: 0)
axis.tickangle.y - Rotation angle for Y-axis tick labels (UI: "Y-axis Tick Label Angle", default: 0)
axis.ticks - Position of tick marks (UI: "Tick Position", default: "outside")
axis.tickcolor - Color of tick marks (UI: "Tick Mark Color", default: "black")
axis.ticklen - Length of tick marks (UI: "Tick Mark Length", default: 5)
axis.tickwidth - Width of tick marks (UI: "Tick Mark Width", default: 1)
hline.intercepts - Y-coordinates for horizontal reference lines (UI: "Y-intercepts", default: "")
hline.colors - Colors for horizontal lines (UI: "Colors", default: "#000000")
hline.widths - Widths for horizontal lines (UI: "Widths", default: "1")
hline.linetypes - Line types for horizontal lines (UI: "Line Types", default: "dashed")
hline.opacities - Opacities for horizontal lines (UI: "Opacities (0-1)", default: "1")
vline.intercepts - X-coordinates for vertical reference lines (UI: "X-intercepts", default: "")
vline.colors - Colors for vertical lines (UI: "Colors", default: "#000000")
vline.widths - Widths for vertical lines (UI: "Widths", default: "1")
vline.linetypes - Line types for vertical lines (UI: "Line Types", default: "dashed")
vline.opacities - Opacities for vertical lines (UI: "Opacities (0-1)", default: "1")
abline.slopes - Slopes for diagonal reference lines (UI: "Slopes", default: "")
abline.intercepts - Y-intercepts for diagonal lines (UI: "Y-intercepts", default: "")
abline.colors - Colors for diagonal lines (UI: "Colors", default: "#000000")
abline.widths - Widths for diagonal lines (UI: "Widths", default: "1")
abline.linetypes - Line types for diagonal lines (UI: "Line Types", default: "dashed")
abline.opacities - Opacities for diagonal lines (UI: "Opacities (0-1)", default: "1")
Jared Andrews, Jacob Martin
dittoViz::yPlot(), organize_inputs(),
dittoViz_yPlotOutputUI(), dittoViz_yPlotServer(),
dittoViz_yPlotApp()
library(VizModules) data(mtcars) dittoViz_yPlotInputsUI("yPlot", mtcars)library(VizModules) data(mtcars) dittoViz_yPlotInputsUI("yPlot", mtcars)
This should be placed in the UI where the plot should be shown.
dittoViz_yPlotOutputUI(id)dittoViz_yPlotOutputUI(id)
id |
The ID for the Shiny module. |
A Shiny plotlyOutput for the yPlot
Jared Andrews
Server logic for yPlot module
dittoViz_yPlotServer( id, data, hide.inputs = NULL, hide.tabs = NULL, defaults = NULL )dittoViz_yPlotServer( id, data, hide.inputs = NULL, hide.tabs = NULL, defaults = NULL )
id |
The ID for the Shiny module. |
data |
A |
hide.inputs |
A character vector of input IDs to hide. These will still be initialized and their values passed to the plot function, but the user will not be able to see/adjust them in the UI. |
hide.tabs |
A character vector of tab names to hide. Inputs in these tabs will still be initialized and their values passed to the plot function, but the user will not be able to see/adjust them in the UI. |
defaults |
A named list of default values for the inputs. When the reset button is clicked, inputs are reset to these values rather than hardcoded fallbacks. Typically the same list passed to the corresponding UI function. |
The moduleServer function for the yPlot module.
Jared Andrews, Jacob Martin
dittoViz::yPlot(), dittoViz_yPlotInputsUI(),
dittoViz_yPlotOutputUI(), dittoViz_yPlotApp()
Generates a customizable interactive dumbbell plot using plotly. Supports single dot mode (1 x variable) or dumbbell mode (2 x variables), with flexible coloring by either X or Y variables, faceting, and transformations.
dumbbellPlot( data, x, y, colour.by = "X variables", palette.selection, show.legend = TRUE, facet.by = NULL, line.colour = "gray80", facet.scales = "fixed", subplot.margin = 0.05, axis.showline = TRUE, axis.mirror = TRUE, axis.linecolor = "black", axis.linewidth = 0.5, axis.tickfont.size = 12, axis.tickfont.color = "black", axis.tickfont.family = "Arial", axis.tickangle.x = 0, axis.tickangle.y = 0, axis.ticks = "outside", axis.tickcolor = "black", axis.ticklen = 5, axis.tickwidth = 1, title.text = "", title.font.size = 26, title.font.family = "Arial", title.font.color = "black", y.title = NULL, x.title = NULL, flip.x = FALSE, flip.y = FALSE, x.adjustment = NULL, order.by = NULL )dumbbellPlot( data, x, y, colour.by = "X variables", palette.selection, show.legend = TRUE, facet.by = NULL, line.colour = "gray80", facet.scales = "fixed", subplot.margin = 0.05, axis.showline = TRUE, axis.mirror = TRUE, axis.linecolor = "black", axis.linewidth = 0.5, axis.tickfont.size = 12, axis.tickfont.color = "black", axis.tickfont.family = "Arial", axis.tickangle.x = 0, axis.tickangle.y = 0, axis.ticks = "outside", axis.tickcolor = "black", axis.ticklen = 5, axis.tickwidth = 1, title.text = "", title.font.size = 26, title.font.family = "Arial", title.font.color = "black", y.title = NULL, x.title = NULL, flip.x = FALSE, flip.y = FALSE, x.adjustment = NULL, order.by = NULL )
data |
A data.frame or tibble containing the data to plot. |
x |
Character vector of column name(s) for x-axis values. Maximum 2 values allowed. If 1 value: creates single dot plot. If 2 values: creates dumbbell plot with connecting segments. |
y |
Character, column name for the y-axis (categorical variable recommended). |
colour.by |
Character, how to color the markers. Options: "X variables" (different colors for each x variable) or "Y variables" (different colors for each y category). Default: "X variables". |
palette.selection |
Character vector of hex colors for marker colors. |
show.legend |
Logical, whether to display the legend. Default: TRUE. |
facet.by |
Optional character, column name to facet plots by. Creates subplots for each unique value. Default: NULL. |
line.colour |
Character, hex color for the connecting lines between dumbbell points. Default: "gray80". |
facet.scales |
Character, controls axis scaling across facets. Options: "fixed" (same for all), "free" (independent), "free_x" (independent x-axis), "free_y" (independent y-axis). Default: "fixed". |
subplot.margin |
Numeric, spacing between facet panels as a fraction of the plot area. Default: 0.06. |
axis.showline |
Logical, whether to show axis border lines. Default: TRUE. |
axis.mirror |
Logical, whether to mirror axis lines on opposite side of plot. Default: TRUE. |
axis.linecolor |
Character, hex color for axis lines. Default: "black". |
axis.linewidth |
Numeric, width of axis lines in pixels. Default: 0.5. |
axis.tickfont.size |
Numeric, font size for axis tick labels. Default: 12. |
axis.tickfont.color |
Character, hex color for axis tick labels. Default: "black". |
axis.tickfont.family |
Character, font family for axis tick labels. Default: "Arial". |
axis.tickangle.x |
Numeric, rotation angle for x-axis tick labels in degrees. Default: 0. |
axis.tickangle.y |
Numeric, rotation angle for y-axis tick labels in degrees. Default: 0. |
axis.ticks |
Character, position of tick marks. Options: "outside", "inside", "none". Default: "outside". |
axis.tickcolor |
Character, hex color for tick marks. Default: "black". |
axis.ticklen |
Numeric, length of tick marks in pixels. Default: 5. |
axis.tickwidth |
Numeric, width of tick marks in pixels. Default: 1. |
title.text |
Character, main title text for the plot. Default: "". |
title.font.size |
Numeric, font size for plot title. Default: 26. |
title.font.family |
Character, font family for plot title. Default: "Arial". |
title.font.color |
Character, hex color for plot title text. Default: "black". |
y.title |
Optional character, label for y-axis. If NULL, auto-generated from column name. Default: NULL. |
x.title |
Optional character, label for x-axis. If NULL, auto-generated from column name. Default: NULL. |
flip.x |
Logical, whether to reverse the x-axis direction. Default: FALSE. |
flip.y |
Logical, whether to reverse the y-axis direction. Default: FALSE. |
x.adjustment |
Optional character or function, transformation to apply to x values. Options: "log2", "log", "log10", "neg_log10", "log1p", "as.factor", "abs", "sqrt", or custom function. Default: NULL. |
order.by |
Optional character vector, column name(s) to order data by before plotting. Default: NULL. |
The dumbbell plot is designed for comparing two values across categories.
Modes:
Single dot mode (1 x variable): Shows one marker per y category
Dumbbell mode (2 x variables): Shows two markers connected by a line per y category
Coloring options:
By X variables: Each x variable gets a different color (e.g., Male=blue, Female=pink)
By Y variables: Each y category gets a different color (e.g., School A=red, School B=blue)
A plotly object representing the interactive dumbbell plot.
Jacob Martin
data <- data.frame( School = c("MIT", "Stanford", "Harvard"), Women = c(152, 96, 112), Men = c(95, 151, 165) ) fig <- dumbbellPlot( data = data, x = c("Women", "Men"), y = "School", colour.by = "X variables", palette.selection = c("green", "blue"), show.legend = TRUE, line.colour = "gray80" )data <- data.frame( School = c("MIT", "Stanford", "Harvard"), Women = c(152, 96, 112), Men = c(95, 151, 165) ) fig <- dumbbellPlot( data = data, x = c("Women", "Men"), y = "School", colour.by = "X variables", palette.selection = c("green", "blue"), show.legend = TRUE, line.colour = "gray80" )
This function generates a Shiny application for interactive dumbbell plots. The app features a Data Import section for uploading data, a Data Table for filtering the active dataset, and a Plot area for configuring and displaying an interactive dumbbell plot.
dumbbellPlotApp(data_list = NULL)dumbbellPlotApp(data_list = NULL)
data_list |
An optional named list of data frames. If |
When data_list is not provided (or NULL), the app launches with
example_school_earnings as an example dataset.
Uploaded data files are added
to the available datasets and can be selected for plotting. If an uploaded
file shares a name with an existing dataset, the existing one is overwritten
with a warning.
This is a convenience wrapper around createModuleApp().
A Shiny app object.
Jacob Martin, Jared Andrews
dumbbellPlot(), dumbbellPlotInputsUI(),
dumbbellPlotOutputUI(), dumbbellPlotServer()
library(VizModules) # Launch with default example data: app <- dumbbellPlotApp() if (interactive()) runApp(app) # Launch with custom data: data <- data.frame( School = c("MIT", "Stanford", "Harvard"), Women = c(94, 96, 112), Men = c(152, 151, 165), Group = c("A", "B", "A") ) app2 <- dumbbellPlotApp(list("School Earnings" = data)) if (interactive()) runApp(app2)library(VizModules) # Launch with default example data: app <- dumbbellPlotApp() if (interactive()) runApp(app) # Launch with custom data: data <- data.frame( School = c("MIT", "Stanford", "Harvard"), Women = c(94, 96, 112), Men = c(152, 151, 165), Group = c("A", "B", "A") ) app2 <- dumbbellPlotApp(list("School Earnings" = data)) if (interactive()) runApp(app2)
This should be placed in the UI where the inputs should be shown, with an id
that matches the id used in the dumbbellPlotServer() and dumbbellPlotOutputUI() functions.
dumbbellPlotInputsUI(id, data, defaults = NULL, title = NULL, columns = 2)dumbbellPlotInputsUI(id, data, defaults = NULL, title = NULL, columns = 2)
id |
The ID for the Shiny module. |
data |
The data frame used for plot generation. |
defaults |
A named list of default values for the inputs. |
title |
An optional title for the UI grid. |
columns |
Number of columns for the UI grid. |
The user inputs for this module are separated from the outputs to allow for more flexible UI design.
The inputs will automatically be organized into a grid layout via the organize_inputs() function,
with columns controlling the number of columns in the grid.
Defaults can be set for each input by providing a named list of values to the defaults argument.
A Shiny tagList containing the UI elements
The following dumbbellPlot() parameters can be accessed via UI inputs:
x - X values (UI: "X Values (max 2)", defaults key: x.value, multiple: TRUE, max 2 enforced)
y - Y value (UI: "Y Value", defaults key: y.value, single selection)
x.adjustment - X-axis transformation (UI: "X Adjustment", default: "")
colour.by - Color by X or Y (UI: "Colour By", default: "X variables")
facet.by - Faceting variable (UI: "Facet By", default: "")
facet.scales - Facet scale behavior (UI: "Facet Scales", default: "fixed")
line.colour - Color of connecting lines (UI: "Colour of Connectors", default: "gray30")
palette.selection - Color palette (UI: palette picker)
The following parameters controlling plotly-specific features and styling are also available:
flip.x - Flip X-axis (UI: "Flip X Axis", default: FALSE)
flip.y - Flip Y-axis (UI: "Flip Y Axis", default: FALSE)
title.font.size - Plot title font size (UI: "Title Size", default: 26)
title.font.family - Font family for title text (UI: "Title Font", default: "Arial")
title.font.color - Color for plot title (UI: "Title Color", default: "#000000")
axis.title.font.size - Axis title font size (UI: "Axis Title Size", default: 18)
axis.title.font.color - Axis title font color (UI: "Axis Title Color", default: "#000000")
axis.title.font.family - Axis title font family (UI: "Axis Title Font", default: "Arial")
axis.showline - Show axis border lines (UI: "Show Axis Borders", default: TRUE)
axis.mirror - Mirror axis lines on opposite side (UI: "Mirror Axis Borders", default: TRUE)
show.grid.x - Show X-axis major gridlines (UI: "Show X Gridlines", default: TRUE)
show.grid.y - Show Y-axis major gridlines (UI: "Show Y Gridlines", default: TRUE)
grid.color - Gridline color (UI: "Gridline Color", default: "#CCCCCC")
axis.linecolor - Color of axis lines (UI: "Axis Line Color", default: "black")
axis.linewidth - Width of axis lines (UI: "Axis Line Width", default: 0.5)
axis.tickfont.size - Size of tick labels (UI: "Tick Label Size", default: 12)
axis.tickfont.color - Color of tick labels (UI: "Tick Label Color", default: "black")
axis.tickfont.family - Font family for tick labels (UI: "Tick Label Font", default: "Arial")
axis.tickangle.x - Rotation angle for X-axis tick labels (UI: "X Tick Label Angle", default: 0)
axis.tickangle.y - Rotation angle for Y-axis tick labels (UI: "Y Tick Label Angle", default: 0)
axis.ticks - Position of tick marks (UI: "Tick Position", default: "outside")
axis.tickcolor - Color of tick marks (UI: "Tick Mark Color", default: "black")
axis.ticklen - Length of tick marks (UI: "Tick Mark Length", default: 5)
axis.tickwidth - Width of tick marks (UI: "Tick Mark Width", default: 1)
facet.title.font.size - Facet subplot title font size (UI: "Facet Subplot Title Size", default: 18)
facet.title.font.color - Facet subplot title font color (UI: "Facet Title Color", default: "#000000")
facet.title.font.family - Facet subplot title font family (UI: "Facet Title Font", default: "Arial")
hline.intercepts - Y-coordinates for horizontal reference lines (UI: "Y-intercepts", default: "")
hline.colors - Colors for horizontal lines (UI: "Colors", default: "#000000")
hline.widths - Widths for horizontal lines (UI: "Widths", default: "1")
hline.linetypes - Line types for horizontal lines (UI: "Line Types", default: "dashed")
hline.opacities - Opacities for horizontal lines (UI: "Opacities (0-1)", default: "1")
vline.intercepts - X-coordinates for vertical reference lines (UI: "X-intercepts", default: "")
vline.colors - Colors for vertical lines (UI: "Colors", default: "#000000")
vline.widths - Widths for vertical lines (UI: "Widths", default: "1")
vline.linetypes - Line types for vertical lines (UI: "Line Types", default: "dashed")
vline.opacities - Opacities for vertical lines (UI: "Opacities (0-1)", default: "1")
margin.t - Top margin in pixels (UI: "Margin Top", default: 70)
margin.b - Bottom margin in pixels (UI: "Margin Bottom", default: 70)
margin.l - Left margin in pixels (UI: "Margin Left", default: 70)
margin.r - Right margin in pixels (UI: "Margin Right", default: 70)
subplot.margin - Spacing between facet panels as fraction of plot area (UI: "Subplot Spacing", default: 0.04)
shape.fill - Fill color for drawn shapes (UI: "Shape Fill", default: "rgba(0, 0, 0, 0)")
shape.line.color - Outline color for drawn shapes (UI: "Shape Line Color", default: "black")
shape.line.width - Outline width for drawn shapes (UI: "Shape Line Width", default: 4)
shape.linetype - Line dash style for drawn shapes (UI: "Shape Linetype", default: "solid")
shape.opacity - Opacity for drawn shapes (UI: "Shape Opacity", default: 1)
Jacob Martin
dumbbellPlot(), organize_inputs(),
dumbbellPlotOutputUI(), dumbbellPlotServer(), dumbbellPlotApp()
library(VizModules) data <- data.frame( School = c("MIT", "Stanford", "Harvard"), Women = c(94, 96, 112), Men = c(152, 151, 165) ) dumbbellPlotInputsUI("dumbbellPlot", data)library(VizModules) data <- data.frame( School = c("MIT", "Stanford", "Harvard"), Women = c(94, 96, 112), Men = c(152, 151, 165) ) dumbbellPlotInputsUI("dumbbellPlot", data)
This should be placed in the UI where the plot should be shown.
dumbbellPlotOutputUI(id)dumbbellPlotOutputUI(id)
id |
The ID for the Shiny module. |
A Shiny plotlyOutput for the dumbbellPlot
Jacob Martin, Jared Andrews
Server logic for dumbbellPlot module
dumbbellPlotServer( id, data, hide.inputs = NULL, hide.tabs = NULL, defaults = NULL )dumbbellPlotServer( id, data, hide.inputs = NULL, hide.tabs = NULL, defaults = NULL )
id |
The ID for the Shiny module. |
data |
A |
hide.inputs |
A character vector of input IDs to hide. These will still be initialized and their values passed to the plot function, but the user will not be able to see/adjust them in the UI. |
hide.tabs |
A character vector of tab names to hide. Inputs in these tabs will still be initialized and their values passed to the plot function, but the user will not be able to see/adjust them in the UI. |
defaults |
A named list of default values for the inputs. When the reset button is clicked, inputs are reset to these values rather than hardcoded fallbacks. Typically the same list passed to the corresponding UI function. |
The moduleServer function for the dumbbellPlot module.
Jacob Martin
dumbbellPlot(), dumbbellPlotInputsUI(),
dumbbellPlotOutputUI(), dumbbellPlotApp()
A small dataset with five groups, two categorical variables, and three
numeric variables. Used as the default data for plotthis_BarPlotApp()
and plotthis_SplitBarPlotApp().
example_barexample_bar
A data frame with 5 rows and 5 columns:
Group label (A through E)
Category type (Alpha, Beta, or Gamma)
Primary numeric values (positive)
Secondary numeric values (can be negative)
Tertiary numeric values (can be negative)
Jacob Martin
Generated in data-raw/generate_example_data.R.
A simulated employee survey dataset with 500 rows spanning six departments and four job levels. Designed to showcase violin, box, yPlot, density, and histogram plot modules with realistic numeric distributions.
example_demographicsexample_demographics
A data frame with 500 rows and 9 columns:
Employee department (factor: Engineering, Marketing, Sales, HR, Finance, Operations)
Job seniority level (factor: Junior, Mid, Senior, Lead)
Employee gender (factor: Male, Female)
Employee age in years
Annual salary in USD
Job satisfaction score (1–10)
Performance rating (1–10)
Years with the company
Average weekly hours worked (35–65)
Jared Andrews
Simulated in data-raw/generate_example_data.R.
The classic iris dataset with an added 'Group' column to facilitate multi-group plot examples.
example_irisexample_iris
A data frame with 150 rows and 6 columns:
Sepal length in cm
Sepal width in cm
Petal length in cm
Petal width in cm
Species of the iris (factor: setosa, versicolor, virginica)
Group assignment (factor: A, B, C, D)
Jared Andrews
Generated from the classic iris dataset.
The classic mtcars dataset with key numeric columns converted to factors for categorical plotting examples.
example_mtcarsexample_mtcars
A data frame with 32 rows and 11 columns:
Miles per gallon
Number of cylinders (factor)
Displacement (cubic inches)
Gross horsepower
Rear axle ratio
Weight (1000 lbs)
1/4 mile time
Engine (0 = V-shaped, 1 = straight) (factor)
Transmission (0 = automatic, 1 = manual) (factor)
Number of forward gears (factor)
Number of carburetors (factor)
Jared Andrews
Generated from the classic mtcars dataset.
Example population dataset A simulated population dataset with 400 rows covering 50 years and 8 age groups. Designed for line, area, and stacked bar plot examples.
example_populationexample_population
A data frame with 400 rows and 4 columns:
Year of the population record (factor: 1975–2024)
Age group category (factor: 0-9, 10-17, 18-34, 35-44, 45-54, 55-64, 65-74, 75+)
Population count for the given year and age group
Unique identifier for each population record
Jared Andrews
Generated in data-raw/generate_example_data.R.
A dataset of role proportions (journalist, developer, designer) for eleven individuals across two teams, suitable for ternary plot examples.
example_rolesexample_roles
A data frame with 11 rows and 5 columns:
Journalist role proportion
Developer role proportion
Designer role proportion
Point label (point 1 through point 11)
Team assignment (Team A or Team B)
Jacob Martin
Generated in data-raw/generate_example_data.R.
A simulated product-sales dataset (720 rows total). Designed to showcase bar, box, violin, area, line, scatter, split-bar, density, and histogram plot modules.
example_salesexample_sales
A data frame with 720 rows and 7 columns:
Region of the sale (factor: North, South, East, West, Central, International)
Revenue for month
The year
The month
Units sold
Unique sale identifier
Product line (factor: Gadgets, Widgets, Doohickeys)
Jared Andrews
Generated in data-raw/generate_example_data.R.
A small dataset of median annual earnings for men and women at six universities, suitable for dumbbell plot examples.
example_school_earningsexample_school_earnings
A data frame with 6 rows and 4 columns:
University name
Median earnings for women (thousands of USD)
Median earnings for men (thousands of USD)
University type (STEM-heavy or Liberal Arts)
Jacob Martin
Generated in data-raw/generate_example_data.R.
A dataset of skill ratings across five categories for three players, suitable for radar/spider chart examples.
example_skillsexample_skills
A data frame with 15 rows and 3 columns:
Skill category (Speed, Strength, Defense, Stamina, Agility)
Skill rating (1-10)
Player identifier (Player A, B, or C)
Jacob Martin
Simulated in data-raw/generate_example_data.R.
Parses the Rd documentation for a given function and extracts parameter descriptions for specified parameter names.
get_documentation(package_name, type = "param", selected = NULL, cap = FALSE)get_documentation(package_name, type = "param", selected = NULL, cap = FALSE)
package_name |
A string in the format "package::function" indicating which function's documentation to parse. |
type |
The type of documentation section to extract. Currently only "param" is supported. |
selected |
A list of parameter names to extract. Note that co-documented
parameters (e.g., |
cap |
Logical; if TRUE, capitalize the first letter of each description. |
A named list where names are parameter names and values are their documentation strings. Returns empty strings for parameters not found in the documentation.
Jacob Martin, Jared Andrews
This function validates that a vector of column names from a data frame contains
columns of only one data type category: either all numeric OR all categorical
(factor/character). Returns FALSE for mixed numeric + categorical columns.
Single columns always return TRUE. Used for Shiny plotting module input validation.
is_pure_type(inputs, d)is_pure_type(inputs, d)
inputs |
Character vector of column names to validate. |
d |
Data frame containing the columns specified in |
Logical scalar: TRUE if all numeric OR all categorical (factor/character);
FALSE if mixed numeric + categorical/factor detected.
Jacob Martin
df <- data.frame(num1 = 1:3, num2 = 4:6, cat1 = letters[1:3], fac1 = factor(1:3)) is_pure_type(c("num1", "num2"), df) # TRUE (all numeric) is_pure_type(c("cat1", "fac1"), df) # TRUE (all categorical) is_pure_type(c("num1"), df) # TRUE (single) is_pure_type(c("num1", "cat1"), df) # FALSE (mixed numeric + cat)df <- data.frame(num1 = 1:3, num2 = 4:6, cat1 = letters[1:3], fac1 = factor(1:3)) is_pure_type(c("num1", "num2"), df) # TRUE (all numeric) is_pure_type(c("cat1", "fac1"), df) # TRUE (all categorical) is_pure_type(c("num1"), df) # TRUE (single) is_pure_type(c("num1", "cat1"), df) # FALSE (mixed numeric + cat)
Generates a customizable interactive line plot using plotly, supporting grouping, faceting, axis adjustments, and color palettes.
linePlot( data, x, y, palette.selection, plot.mode = "lines", line.type = "solid", colour.group.by = NULL, show.legend = TRUE, facet.by = NULL, facet.scales = "fixed", subplot.margin = 0.05, axis.showline = TRUE, axis.mirror = TRUE, axis.linecolor = "black", axis.linewidth = 0.5, axis.tickfont.size = 12, axis.tickfont.color = "black", axis.tickfont.family = "Arial", axis.tickangle.x = 0, axis.tickangle.y = 0, axis.ticks = "outside", axis.tickcolor = "black", axis.ticklen = 5, axis.tickwidth = 1, show.grid.x = TRUE, show.grid.y = TRUE, title.text = "", title.font.size = 14, title.font.family = "Arial", title.font.color = "black", y.title = NULL, x.title = NULL, flip.x = FALSE, flip.y = FALSE, x.adjustment = NULL, y.adjustment = NULL, color.adjustment = NULL, order.by = NULL, error.colour = NULL, error.width = NULL, error.bar = FALSE )linePlot( data, x, y, palette.selection, plot.mode = "lines", line.type = "solid", colour.group.by = NULL, show.legend = TRUE, facet.by = NULL, facet.scales = "fixed", subplot.margin = 0.05, axis.showline = TRUE, axis.mirror = TRUE, axis.linecolor = "black", axis.linewidth = 0.5, axis.tickfont.size = 12, axis.tickfont.color = "black", axis.tickfont.family = "Arial", axis.tickangle.x = 0, axis.tickangle.y = 0, axis.ticks = "outside", axis.tickcolor = "black", axis.ticklen = 5, axis.tickwidth = 1, show.grid.x = TRUE, show.grid.y = TRUE, title.text = "", title.font.size = 14, title.font.family = "Arial", title.font.color = "black", y.title = NULL, x.title = NULL, flip.x = FALSE, flip.y = FALSE, x.adjustment = NULL, y.adjustment = NULL, color.adjustment = NULL, order.by = NULL, error.colour = NULL, error.width = NULL, error.bar = FALSE )
data |
A data.frame or tibble containing the data to plot. |
x |
Character vector of column name(s) for the x-axis. Multiple columns create separate traces. |
y |
Character vector of column name(s) for the y-axis. Multiple columns create separate traces. |
palette.selection |
Character vector of hex colors for line colors. Used to assign colors to groups or traces. |
plot.mode |
Character, plotly mode for plot type. Options: "lines", "markers", "lines+markers". Default: "lines". |
line.type |
Character, line style. Options: "solid", "dot", "dash", "longdash", "dashdot", "longdashdot". Default: "solid". |
colour.group.by |
Character or formula, column name(s) to group lines by color.
Can be a formula like |
show.legend |
Logical, whether to display the legend. Default: TRUE. |
facet.by |
Optional character, column name to facet plots by. Creates subplots for each unique value. Default: NULL. |
facet.scales |
Character, controls axis scaling across facets. Options: "fixed" (same for all), "free" (independent), "free_x" (independent x-axis), "free_y" (independent y-axis). Default: "fixed". |
subplot.margin |
Numeric, spacing between facet panels as a fraction of the plot area. Default: 0.05. |
axis.showline |
Logical, whether to show axis border lines. Default: TRUE. |
axis.mirror |
Logical, whether to mirror axis lines on opposite side of plot. Default: TRUE. |
axis.linecolor |
Character, hex color for axis lines. Default: "black". |
axis.linewidth |
Numeric, width of axis lines in pixels. Default: 0.5. |
axis.tickfont.size |
Numeric, font size for axis tick labels. Default: 12. |
axis.tickfont.color |
Character, hex color for axis tick labels. Default: "black". |
axis.tickfont.family |
Character, font family for axis tick labels. Default: "Arial". |
axis.tickangle.x |
Numeric, rotation angle for x-axis tick labels in degrees. Default: 0. |
axis.tickangle.y |
Numeric, rotation angle for y-axis tick labels in degrees. Default: 0. |
axis.ticks |
Character, position of tick marks. Options: "outside", "inside", "none". Default: "outside". |
axis.tickcolor |
Character, hex color for tick marks. Default: "black". |
axis.ticklen |
Numeric, length of tick marks in pixels. Default: 5. |
axis.tickwidth |
Numeric, width of tick marks in pixels. Default: 1. |
show.grid.x |
Logical, whether to show gridlines on the x-axis. Default: TRUE. |
show.grid.y |
Logical, whether to show gridlines on the y-axis. Default: TRUE. |
title.text |
Character, main title text for the plot. Default: "". |
title.font.size |
Numeric, font size for plot title. Default: 14. |
title.font.family |
Character, font family for plot title. Default: "Arial". |
title.font.color |
Character, hex color for plot title text. Default: "black". |
y.title |
Optional character, label for y-axis. If NULL, auto-generated from column name. Default: NULL. |
x.title |
Optional character, label for x-axis. If NULL, auto-generated from column name. Default: NULL. |
flip.x |
Logical, whether to reverse the x-axis direction. Default: FALSE. |
flip.y |
Logical, whether to reverse the y-axis direction. Default: FALSE. |
x.adjustment |
Optional character or function, transformation to apply to x values. Options: "log2", "log", "log10", "neg_log10", "log1p", "as.factor", "abs", "sqrt", or custom function. Default: NULL. |
y.adjustment |
Optional character or function, transformation to apply to y values. Options: "log2", "log", "log10", "neg_log10", "log1p", "as.factor", "abs", "sqrt", or custom function. Default: NULL. |
color.adjustment |
Optional character or function, transformation to apply to color grouping variable. Same options as x.adjustment and y.adjustment. Default: NULL. |
order.by |
Optional character vector, column name(s) to order data by before plotting. Default: NULL. |
error.colour |
hex colour input to set the colour of the error bars on a plot with a categorical X axis and only 1 Y axis variable |
error.width |
numeric input to set the width of the error bars on a plot with a categorical X axis and only 1 Y axis variable |
error.bar |
Boolean value to determine if error bars will be on or off on a plot with a categorical X axis and only 1 Y axis variable |
A plotly object representing the interactive line plot.
Jacob Martin, Jared Andrews
palette <- plotthis::palette_list[["Set2"]] fig <- linePlot( data = mtcars, x = "cyl", y = "mpg", plot.mode = "lines", line.type = "solid", colour.group.by = "mpg", palette.selection = palette, show.legend = TRUE )palette <- plotthis::palette_list[["Set2"]] fig <- linePlot( data = mtcars, x = "cyl", y = "mpg", plot.mode = "lines", line.type = "solid", colour.group.by = "mpg", palette.selection = palette, show.legend = TRUE )
This function generates a Shiny application with modular linePlot() components.
The app features a Data Import section for uploading data,
a Data Table for filtering the active dataset, and a Plot area
for configuring and displaying an interactive line plot.
linePlotApp(data_list = NULL)linePlotApp(data_list = NULL)
data_list |
An optional named list of data frames. If |
When data_list is not provided (or NULL), the app launches with
gallery_sales as an example dataset. Uploaded data files are added
to the available datasets and can be selected for plotting. If an uploaded
file shares a name with an existing dataset, the existing one is overwritten
with a warning.
This is a convenience wrapper around createModuleApp().
A Shiny app object.
Jacob Martin, Jared Andrews
linePlot(), linePlotInputsUI(),
linePlotOutputUI(), linePlotServer()
library(VizModules) # Launch with default example data (example_sales): app <- linePlotApp() if (interactive()) runApp(app) # Launch with custom data: app2 <- linePlotApp(list("sales" = example_sales)) if (interactive()) runApp(app2)library(VizModules) # Launch with default example data (example_sales): app <- linePlotApp() if (interactive()) runApp(app) # Launch with custom data: app2 <- linePlotApp(list("sales" = example_sales)) if (interactive()) runApp(app2)
This should be placed in the UI where the inputs should be shown, with an id
that matches the id used in the linePlotServer() and linePlotOutputUI() functions.
linePlotInputsUI(id, data, defaults = NULL, title = NULL, columns = 2)linePlotInputsUI(id, data, defaults = NULL, title = NULL, columns = 2)
id |
The ID for the Shiny module. |
data |
The data frame used for plot generation. |
defaults |
A named list of default values for the inputs. |
title |
An optional title for the UI grid. |
columns |
Number of columns for the UI grid. |
The user inputs for this module are separated from the outputs to allow for more flexible UI design.
The inputs will automatically be organized into a grid layout via the organize_inputs() function,
with columns controlling the number of columns in the grid.
Defaults can be set for each input by providing a named list of values to the defaults argument.
Nearly all parameters for linePlot() can be set via these inputs, so see the help
for that function for an exhaustive list.
A Shiny tagList containing the UI elements
The following linePlot() parameters can be accessed via UI inputs and/or the defaults argument:
x - X-axis variable(s) (UI: "Select X values", defaults key: x.value, default: 1st column, multiple: TRUE)
y - Y-axis variable(s) (UI: "Select Y values", defaults key: y.value, default: 2nd column, multiple: TRUE)
title.font.size - Plot title font size (UI: "Title Size", default: 26)
title.font.family - Font family for title text (UI: "Title Font", default: "Arial")
title.font.color - Color for plot title (UI: "Title Color", default: "#000000")
axis.title.font.size - Axis title font size (UI: "Axis Title Size", default: 18)
axis.title.font.color - Axis title font color (UI: "Axis Title Color", default: "#000000")
axis.title.font.family - Axis title font family (UI: "Axis Title Font", default: "Arial")
group.by - Grouping variable (UI: "Group by", default: 1st categorical variable)
order.by - Order by Y values (UI: "Order by Y", default: FALSE)
x.adjustment - X-axis adjustment function (UI: "X Adjustment", default: "")
y.adjustment - Y-axis adjustment function (UI: "Y Adjustment", default: "")
facet.by - Faceting variable (UI: "Facet by", default: "")
facet.scales - Facet scale behavior (UI: "Facet scales", default: "fixed")
plot.mode - Plot type (UI: "Plot type", default: "lines")
line.type - Line type (UI: "Line type", default: "solid")
palette.selection - Color palette (UI: palette picker, derived from palette)
axis.showline - Show axis border lines (UI: "Show Axis Borders", default: TRUE)
axis.mirror - Mirror axis lines on opposite side (UI: "Mirror Axis Borders", default: TRUE)
axis.linecolor - Color of axis lines (UI: "Axis Line Color", default: "black")
axis.linewidth - Width of axis lines (UI: "Axis Line Width", default: 0.5)
axis.tickfont.size - Size of tick labels (UI: "Tick Label Size", default: 12)
axis.tickfont.color - Color of tick labels (UI: "Tick Label Color", default: "black")
axis.tickfont.family - Font family for tick labels (UI: "Tick Label Font", default: "Arial")
axis.tickangle.x - Rotation angle for X-axis tick labels (UI: "X Tick Label Angle", default: 0)
axis.tickangle.y - Rotation angle for Y-axis tick labels (UI: "Y Tick Label Angle", default: 0)
axis.ticks - Position of tick marks (UI: "Tick Position", default: "outside")
axis.tickcolor - Color of tick marks (UI: "Tick Mark Color", default: "black")
axis.ticklen - Length of tick marks (UI: "Tick Mark Length", default: 5)
axis.tickwidth - Width of tick marks (UI: "Tick Mark Width", default: 1)
facet.title.font.size - Facet subplot title font size (UI: "Facet Subplot Title Size", default: 18)
facet.title.font.color - Facet subplot title font color (UI: "Facet Title Color", default: "#000000")
facet.title.font.family - Facet subplot title font family (UI: "Facet Title Font", default: "Arial")
show.grid.x - Show X-axis gridlines (UI: "Show X Gridlines", default: TRUE)
show.grid.y - Show Y-axis gridlines (UI: "Show Y Gridlines", default: TRUE)
grid.color - Gridline color (UI: "Gridline Color", default: "#CCCCCC")
x.title - X-axis title (auto-calculated from data)
y.title - Y-axis title (auto-calculated from data)
flip.x - Flip X-axis (UI: "Flip X", default: FALSE)
flip.y - Flip Y-axis (UI: "Flip Y", default: FALSE)
The following parameters implementing plotly-specific features are also available:
hline.intercepts - Y-coordinates for horizontal reference lines (UI: "Y-intercepts", default: "")
hline.colors - Colors for horizontal lines (UI: "Colors", default: "#000000")
hline.widths - Widths for horizontal lines (UI: "Widths", default: "1")
hline.linetypes - Line types for horizontal lines (UI: "Line Types", default: "dashed")
hline.opacities - Opacities for horizontal lines (UI: "Opacities (0-1)", default: "1")
vline.intercepts - X-coordinates for vertical reference lines (UI: "X-intercepts", default: "")
vline.colors - Colors for vertical lines (UI: "Colors", default: "#000000")
vline.widths - Widths for vertical lines (UI: "Widths", default: "1")
vline.linetypes - Line types for vertical lines (UI: "Line Types", default: "dashed")
vline.opacities - Opacities for vertical lines (UI: "Opacities (0-1)", default: "1")
abline.slopes - Slopes for diagonal reference lines (UI: "Slopes", default: "")
abline.intercepts - Y-intercepts for diagonal lines (UI: "Y-intercepts", default: "")
abline.colors - Colors for diagonal lines (UI: "Colors", default: "#000000")
abline.widths - Widths for diagonal lines (UI: "Widths", default: "1")
abline.linetypes - Line types for diagonal lines (UI: "Line Types", default: "dashed")
abline.opacities - Opacities for diagonal lines (UI: "Opacities (0-1)", default: "1")
Jacob Martin, Jared Andrews
linePlot(), organize_inputs(),
linePlotOutputUI(), linePlotServer(), linePlotApp()
library(VizModules) data(mtcars) linePlotInputsUI("linePlot", mtcars)library(VizModules) data(mtcars) linePlotInputsUI("linePlot", mtcars)
This should be placed in the UI where the plot should be shown.
linePlotOutputUI(id)linePlotOutputUI(id)
id |
The ID for the Shiny module. |
A Shiny plotlyOutput for the linePlot
Jacob Martin
Server logic for linePlot module
linePlotServer(id, data, hide.inputs = NULL, hide.tabs = NULL, defaults = NULL)linePlotServer(id, data, hide.inputs = NULL, hide.tabs = NULL, defaults = NULL)
id |
The ID for the Shiny module. |
data |
A |
hide.inputs |
A character vector of input IDs to hide. These will still be initialized and their values passed to the plot function, but the user will not be able to see/adjust them in the UI. |
hide.tabs |
A character vector of tab names to hide. Inputs in these tabs will still be initialized and their values passed to the plot function, but the user will not be able to see/adjust them in the UI. |
defaults |
A named list of default values for the inputs. When the reset button is clicked, inputs are reset to these values rather than hardcoded fallbacks. Typically the same list passed to the corresponding UI function. |
The moduleServer function for the linePlot module.
Jacob Martin
linePlot(), linePlotInputsUI(),
linePlotOutputUI(), linePlotApp()
Generates a consistent set of control buttons for VizModules that includes Auto Update toggle, Update and Reset buttons, an optional Stats download button, and the "Plotly" tab containing plot margin and shape annotation controls.
module_tack_ui(ns, defaults = NULL, has.stats = FALSE)module_tack_ui(ns, defaults = NULL, has.stats = FALSE)
ns |
Namespace function from the module (e.g., |
defaults |
Optional named list of default values. Reserved for future use. |
has.stats |
Logical; if TRUE, include a "Save Stats" download button. Default FALSE. |
A Shiny tagList containing the standard control buttons and inputs.
Jared Andrews
library(VizModules) library(shiny) ns <- NS("myModule") module_tack_ui(ns)library(VizModules) library(shiny) ns <- NS("myModule") module_tack_ui(ns)
Build a compact Shiny input that assigns colors to a set of groups using a
palette or manual hex pickers. The value returned to input[[inputId]] is a
named character vector of hex colors keyed by group.
multiColorPicker( inputId, label = NULL, groups, palette_options = NULL, selected_palette = NULL, colors = NULL, width = NULL, show_text = TRUE, compact = FALSE, panel = TRUE )multiColorPicker( inputId, label = NULL, groups, palette_options = NULL, selected_palette = NULL, colors = NULL, width = NULL, show_text = TRUE, compact = FALSE, panel = TRUE )
inputId |
Character. Shiny input id. |
label |
Optional label displayed above the control. |
groups |
Character or factor vector of group names. |
palette_options |
Named list of palettes (each a character vector of
colors). Defaults to the palettes from |
selected_palette |
Optional name of the palette to preselect. |
colors |
Optional named vector of starting colors. Values are matched to
|
width |
Optional CSS width for the container. |
show_text |
Logical. If |
compact |
Logical. If |
panel |
Logical. If |
A UI element that produces a named character vector of colors.
Jared Andrews
if (interactive()) { library(shiny) groups <- c("setosa", "virginica", "versicolor") ui <- fluidPage( multiColorPicker( "species_cols", "Species colors", groups = groups, selected_palette = "dittoColors" ), verbatimTextOutput("chosen") ) server <- function(input, output, session) { output$chosen <- renderPrint(input$species_cols) } shinyApp(ui, server) }if (interactive()) { library(shiny) groups <- c("setosa", "virginica", "versicolor") ui <- fluidPage( multiColorPicker( "species_cols", "Species colors", groups = groups, selected_palette = "dittoColors" ), verbatimTextOutput("chosen") ) server <- function(input, output, session) { output$chosen <- renderPrint(input$species_cols) } shinyApp(ui, server) }
Organize arbitrary Shiny inputs into a grid layout
organize_inputs( tag.list, id = NULL, title = NULL, tack = NULL, columns = NULL, rows = NULL )organize_inputs( tag.list, id = NULL, title = NULL, tack = NULL, columns = NULL, rows = NULL )
tag.list |
A tagList containing UI inputs or a named list containing multiple tagLists containing UI inputs. |
id |
An optional ID for the tabsetPanel if a named list is provided. |
title |
An optional title for the grid, should be a UI element, e.g. h3("Title"). |
tack |
An optional UI input to tack onto the end of the grid. |
columns |
Number of columns. |
rows |
Number of rows. |
A Shiny tagList with inputs organized into a grid, optionally nested inside a tabsetPanel.
Jared Andrews
library(VizModules) # Example 1: Basic usage with a simple grid ui.inputs <- tagList( textInput("name", "Name"), numericInput("age", "Age", value = 30), selectInput("gender", "Gender", choices = c("Male", "Female", "Other")) ) organize_inputs(ui.inputs, columns = 2, rows = 2) # Example 2: Using a named list to create tabs ui.inputs.tabs <- list( Personal = tagList( textInput("firstname", "First Name"), textInput("lastname", "Last Name") ), Settings = tagList( checkboxInput("newsletter", "Subscribe to newsletter", value = TRUE), sliderInput("volume", "Volume", min = 0, max = 100, value = 50) ) ) organize_inputs(ui.inputs.tabs, columns = 1) # Example 3: Adding an additional UI element with 'tack' additional.ui <- actionButton("submit", "Submit") organize_inputs(ui.inputs, tack = additional.ui, columns = 3) # Example 4: Handling a case with more inputs than grid cells many.inputs <- tagList(replicate(10, textInput("input", "Input"))) organize_inputs(many.inputs, columns = 3) # Creates more than one rowlibrary(VizModules) # Example 1: Basic usage with a simple grid ui.inputs <- tagList( textInput("name", "Name"), numericInput("age", "Age", value = 30), selectInput("gender", "Gender", choices = c("Male", "Female", "Other")) ) organize_inputs(ui.inputs, columns = 2, rows = 2) # Example 2: Using a named list to create tabs ui.inputs.tabs <- list( Personal = tagList( textInput("firstname", "First Name"), textInput("lastname", "Last Name") ), Settings = tagList( checkboxInput("newsletter", "Subscribe to newsletter", value = TRUE), sliderInput("volume", "Volume", min = 0, max = 100, value = 50) ) ) organize_inputs(ui.inputs.tabs, columns = 1) # Example 3: Adding an additional UI element with 'tack' additional.ui <- actionButton("submit", "Submit") organize_inputs(ui.inputs, tack = additional.ui, columns = 3) # Example 4: Handling a case with more inputs than grid cells many.inputs <- tagList(replicate(10, textInput("input", "Input"))) organize_inputs(many.inputs, columns = 3) # Creates more than one row
Generates a customizable interactive parallel coordinates plot using plotly, supporting dimension selection, color mapping, and font styling.
parallelCoordinatesPlot( data, dimensions, color.by = NULL, color.scale = "Viridis", line.opacity = 0.5, line.width = 1, show.colorbar = TRUE, label.font.size = 12, label.font.color = "black", label.font.family = "Arial", tick.font.size = 10, tick.font.color = "black", tick.font.family = "Arial", title.text = "", title.font.size = 16, title.font.family = "Arial", title.font.color = "black", bgcolor = "#FFFFFF" )parallelCoordinatesPlot( data, dimensions, color.by = NULL, color.scale = "Viridis", line.opacity = 0.5, line.width = 1, show.colorbar = TRUE, label.font.size = 12, label.font.color = "black", label.font.family = "Arial", tick.font.size = 10, tick.font.color = "black", tick.font.family = "Arial", title.text = "", title.font.size = 16, title.font.family = "Arial", title.font.color = "black", bgcolor = "#FFFFFF" )
data |
A data.frame or tibble containing the data to plot. |
dimensions |
Character vector of column names to use as dimensions (axes). Must contain at least two columns. Non-numeric columns are mapped to integers. |
color.by |
Optional character, column name to color lines by. Numeric columns use a continuous colorscale; categorical columns are mapped to integers and displayed with the same colorscale. Default: NULL. |
color.scale |
Character, plotly colorscale name for line coloring. Options include "Viridis", "Cividis", "Inferno", "Magma", "Plasma", "Blues", "Greens", "Reds", "Oranges", "RdBu", "RdYlBu", "Spectral", "Jet", "Hot", "Cool", "Portland". Default: "Viridis". |
line.opacity |
Numeric, opacity of lines between 0 and 1. Default: 0.5. |
line.width |
Numeric, width of lines in pixels. Default: 1. |
show.colorbar |
Logical, whether to show the colorbar. Default: TRUE. |
label.font.size |
Numeric, font size for dimension labels. Default: 12. |
label.font.color |
Character, hex color for dimension labels. Default: "black". |
label.font.family |
Character, font family for dimension labels. Default: "Arial". |
tick.font.size |
Numeric, font size for axis tick labels. Default: 10. |
tick.font.color |
Character, hex color for axis tick labels. Default: "black". |
tick.font.family |
Character, font family for axis tick labels. Default: "Arial". |
title.text |
Character, main title text for the plot. Default: "". |
title.font.size |
Numeric, font size for plot title. Default: 16. |
title.font.family |
Character, font family for plot title. Default: "Arial". |
title.font.color |
Character, hex color for plot title text. Default: "black". |
bgcolor |
Character, hex color for the plot background. Default: "#FFFFFF". |
A plotly object representing the interactive parallel coordinates plot.
Jacob Martin, Jared Andrews
fig <- parallelCoordinatesPlot( data = mtcars, dimensions = c("mpg", "cyl", "disp", "hp", "wt"), color.by = "mpg", color.scale = "Viridis", line.opacity = 0.6 )fig <- parallelCoordinatesPlot( data = mtcars, dimensions = c("mpg", "cyl", "disp", "hp", "wt"), color.by = "mpg", color.scale = "Viridis", line.opacity = 0.6 )
This function generates a Shiny application with modular
parallelCoordinatesPlot() components.
The app features a Data Import section for uploading data,
a Data Table for filtering the active dataset, and a Plot area
for configuring and displaying an interactive parallel coordinates plot.
parallelCoordinatesPlotApp(data_list = NULL)parallelCoordinatesPlotApp(data_list = NULL)
data_list |
An optional named list of data frames. If |
When data_list is not provided (or NULL), the app launches with
gallery_sales as an example dataset. Uploaded data files are added
to the available datasets and can be selected for plotting. If an uploaded
file shares a name with an existing dataset, the existing one is overwritten
with a warning.
This is a convenience wrapper around createModuleApp().
A Shiny app object.
Jacob Martin, Jared Andrews
parallelCoordinatesPlot(), parallelCoordinatesPlotInputsUI(),
parallelCoordinatesPlotOutputUI(), parallelCoordinatesPlotServer()
library(VizModules) # Launch with default example data: app <- parallelCoordinatesPlotApp() if (interactive()) runApp(app) # Launch with custom data: app2 <- parallelCoordinatesPlotApp(list("sales" = example_sales)) if (interactive()) runApp(app2)library(VizModules) # Launch with default example data: app <- parallelCoordinatesPlotApp() if (interactive()) runApp(app) # Launch with custom data: app2 <- parallelCoordinatesPlotApp(list("sales" = example_sales)) if (interactive()) runApp(app2)
This should be placed in the UI where the inputs should be shown, with an id
that matches the id used in the parallelCoordinatesPlotServer() and
parallelCoordinatesPlotOutputUI() functions.
parallelCoordinatesPlotInputsUI( id, data, defaults = NULL, title = NULL, columns = 2 )parallelCoordinatesPlotInputsUI( id, data, defaults = NULL, title = NULL, columns = 2 )
id |
The ID for the Shiny module. |
data |
The data frame used for plot generation. |
defaults |
A named list of default values for the inputs. |
title |
An optional title for the UI grid. |
columns |
Number of columns for the UI grid. |
The user inputs for this module are separated from the outputs to allow for more flexible UI design.
The inputs will automatically be organized into a grid layout via the organize_inputs() function,
with columns controlling the number of columns in the grid.
Defaults can be set for each input by providing a named list of values to the defaults argument.
Nearly all parameters for parallelCoordinatesPlot() can be set via these inputs,
so see the help for that function for an exhaustive list.
A Shiny tagList containing the UI elements
The following parallelCoordinatesPlot() parameters can be accessed via UI inputs
and/or the defaults argument:
title.font.size - Plot title font size (UI: "Title Size", default: 26)
title.font.family - Font family for title text (UI: "Title Font", default: "Arial")
title.font.color - Color for plot title (UI: "Title Color", default: "#000000")
dimensions - Columns to use as axes (UI: "Select dimensions", multiple: TRUE)
color.by - Column to color lines by (UI: "Color by", default: "")
color.scale - Colorscale for lines (UI: "Color scale", default: "Viridis")
line.opacity - Line opacity (UI: "Line opacity", default: 0.5)
line.width - Line width (UI: "Line width", default: 1)
show.colorbar - Show colorbar (UI: "Show colorbar", default: TRUE)
label.font.size - Dimension label font size (UI: "Label font size", default: 12)
label.font.color - Dimension label font color (UI: "Label font color", default: "black")
label.font.family - Dimension label font family (UI: "Label font", default: "Arial")
tick.font.size - Tick label font size (UI: "Tick font size", default: 10)
tick.font.color - Tick label font color (UI: "Tick font color", default: "black")
tick.font.family - Tick label font family (UI: "Tick font", default: "Arial")
bgcolor - Plot background color (UI: "Background color", default: "#FFFFFF")
Jacob Martin, Jared Andrews
parallelCoordinatesPlot(), organize_inputs(),
parallelCoordinatesPlotOutputUI(), parallelCoordinatesPlotServer(),
parallelCoordinatesPlotApp()
library(VizModules) parallelCoordinatesPlotInputsUI("parcoords", mtcars)library(VizModules) parallelCoordinatesPlotInputsUI("parcoords", mtcars)
This should be placed in the UI where the plot should be shown.
parallelCoordinatesPlotOutputUI(id)parallelCoordinatesPlotOutputUI(id)
id |
The ID for the Shiny module. |
A Shiny plotlyOutput for the parallelCoordinatesPlot
Jacob Martin, Jared Andrews
Server logic for parallelCoordinatesPlot module
parallelCoordinatesPlotServer( id, data, hide.inputs = NULL, hide.tabs = NULL, defaults = NULL )parallelCoordinatesPlotServer( id, data, hide.inputs = NULL, hide.tabs = NULL, defaults = NULL )
id |
The ID for the Shiny module. |
data |
A |
hide.inputs |
A character vector of input IDs to hide. These will still be initialized and their values passed to the plot function, but the user will not be able to see/adjust them in the UI. |
hide.tabs |
A character vector of tab names to hide. Inputs in these tabs will still be initialized and their values passed to the plot function, but the user will not be able to see/adjust them in the UI. |
defaults |
A named list of default values for the inputs. When the reset button is clicked, inputs are reset to these values rather than hardcoded fallbacks. Typically the same list passed to the corresponding UI function. |
The moduleServer function for the parallelCoordinatesPlot module.
Jacob Martin, Jared Andrews
parallelCoordinatesPlot(), parallelCoordinatesPlotInputsUI(),
parallelCoordinatesPlotOutputUI(), parallelCoordinatesPlotApp()
Create a plotly pie chart
piePlot( df, labels, values, colors = NULL, palette = NULL, hole = 0, textinfo = "label+percent", textposition = "auto", insidetextorientation = "auto", sort = TRUE, direction = "counterclockwise", rotation = 0, show.legend = TRUE, legend.orientation = "h", legend.x = 0.5, legend.y = -0.1, legend.font.family = "Arial", legend.font.size = 12, legend.font.color = "#000000", title.text = "", title.font.family = "Arial", title.font.size = 18, title.font.color = "#000000", title.x = 0.5, text.font.family = "Arial", text.font.size = 12, text.font.color = "#000000", slice.line.color = "#FFFFFF", slice.line.width = 0 )piePlot( df, labels, values, colors = NULL, palette = NULL, hole = 0, textinfo = "label+percent", textposition = "auto", insidetextorientation = "auto", sort = TRUE, direction = "counterclockwise", rotation = 0, show.legend = TRUE, legend.orientation = "h", legend.x = 0.5, legend.y = -0.1, legend.font.family = "Arial", legend.font.size = 12, legend.font.color = "#000000", title.text = "", title.font.family = "Arial", title.font.size = 18, title.font.color = "#000000", title.x = 0.5, text.font.family = "Arial", text.font.size = 12, text.font.color = "#000000", slice.line.color = "#FFFFFF", slice.line.width = 0 )
df |
A data frame where each row already represents a summarized slice (e.g., counts per category) with label and value columns. |
labels |
Character, name of the column to use for the slice labels. |
values |
Character, name of the column to use for the aggregated values (slice sizes). |
colors |
Optional character vector of hex colors for the slices.
If named, values are matched to the values in |
palette |
Optional character vector of fallback colors used when
|
hole |
Numeric value between 0 and 1 for the hole size (0 for pie chart, >0 for donut chart). Default: 0. |
textinfo |
Character string specifying the text info to show on slices. Any combination of "label", "text", "value", "percent" joined with a "+" (e.g., "label+percent") or "none" to hide text. Default: "label+percent". |
textposition |
Character, position of the text relative to the slice. Options: "auto", "inside", "outside", or "none". Default: "auto". |
insidetextorientation |
Character, orientation for inside text. Options: "auto", "horizontal", "radial", or "tangential". Default: "auto". |
sort |
Logical, whether to sort slices by their values in descending order. Default: TRUE. |
direction |
Character, direction of slice progression. Options: "counterclockwise" or "clockwise". Default: "counterclockwise". |
rotation |
Numeric, starting angle of the first slice in degrees (0-360). Default: 0. |
show.legend |
Logical, whether to display the legend. Default: TRUE. |
legend.orientation |
Character, legend orientation. Options: "h" (horizontal) or "v" (vertical). Default: "h". |
legend.x |
Numeric, horizontal legend position offset (0-1, where 0=left, 1=right). Default: 0.5. |
legend.y |
Numeric, vertical legend position offset (-1 to 1). Default: -0.1. |
legend.font.family |
Character, font family for the legend text. Default: "Arial". |
legend.font.size |
Numeric, font size for the legend text. Default: 12. |
legend.font.color |
Character, hex color for the legend text. Default: "#000000". |
title.text |
Character, main plot title text. Default: "". |
title.font.family |
Character, font family for the title text. Default: "Arial". |
title.font.size |
Numeric, font size for the title text. Default: 18. |
title.font.color |
Character, hex color for the title text. Default: "#000000". |
title.x |
Numeric, horizontal position for the plot title (0-1, where 0=left, 0.5=center, 1=right). Default: 0.5. |
text.font.family |
Character, font family for the slice labels. Default: "Arial". |
text.font.size |
Numeric, font size for the slice labels. Default: 12. |
text.font.color |
Character, hex color for the slice labels. Default: "#000000". |
slice.line.color |
Character, hex color for slice borders. Default: "#FFFFFF" (white). |
slice.line.width |
Numeric, width of slice borders in pixels. Set to 0 for no borders. Default: 0. |
A plotly object.
Jacob Martin, Jared Andrews
status_counts <- data.frame( status = c("Upregulated", "Downregulated", "Not significant"), n = c(12, 7, 3) ) piePlot( df = status_counts, labels = "status", values = "n", palette = c("#1B9E77", "#D95F02", "#7570B3"), sort = FALSE, title.text = "Genes by status" )status_counts <- data.frame( status = c("Upregulated", "Downregulated", "Not significant"), n = c(12, 7, 3) ) piePlot( df = status_counts, labels = "status", values = "n", palette = c("#1B9E77", "#D95F02", "#7570B3"), sort = FALSE, title.text = "Genes by status" )
This function generates a Shiny application with modular piePlot components. The app features a Data Import section for uploading data, a Data Table for filtering the active dataset, and a Plot area for configuring and displaying an interactive pie plot.
piePlotApp(data_list = NULL)piePlotApp(data_list = NULL)
data_list |
An optional named list of summary data frames (one row per slice).
If |
When data_list is not provided (or NULL), the app launches with
an aggregated example_sales dataset (revenue by product line). Uploaded data files are added
to the available datasets and can be selected for plotting. If an uploaded
file shares a name with an existing dataset, the existing one is overwritten
with a warning.
This is a convenience wrapper around createModuleApp().
A Shiny app object.
Jacob Martin, Jared Andrews
piePlot(), piePlotInputsUI(),
piePlotOutputUI(), piePlotServer()
library(VizModules) # Launch with default example data: app <- piePlotApp() if (interactive()) runApp(app) # Launch with custom data: sales_summary <- aggregate(revenue ~ product_line, example_sales, sum) app2 <- piePlotApp(list("sales" = sales_summary)) if (interactive()) runApp(app2)library(VizModules) # Launch with default example data: app <- piePlotApp() if (interactive()) runApp(app) # Launch with custom data: sales_summary <- aggregate(revenue ~ product_line, example_sales, sum) app2 <- piePlotApp(list("sales" = sales_summary)) if (interactive()) runApp(app2)
This should be placed in the UI where the inputs should be shown, with an id
that matches the id used in the piePlotServer() and piePlotOutputUI() functions.
piePlotInputsUI(id, data, defaults = NULL, title = NULL, columns = 2)piePlotInputsUI(id, data, defaults = NULL, title = NULL, columns = 2)
id |
The ID for the Shiny module. |
data |
The data frame used for plot generation. Supply a summary table with one row per slice. |
defaults |
A named list of default values for the inputs. |
title |
An optional title for the UI grid. |
columns |
Number of columns for the UI grid. |
The user inputs for this module are separated from the outputs to allow for more flexible UI design.
The inputs will automatically be organized into a grid layout via the organize_inputs() function,
with columns controlling the number of columns in the grid.
Defaults can be set for each input by providing a named list of values to the defaults argument.
Provide summarized data (one row per slice) with columns for labels and aggregated values.
Nearly all parameters for piePlot() can be set via these inputs, so see the help
for that function for an exhaustive list.
A Shiny tagList containing the UI elements
The following piePlot() parameters can be accessed via UI inputs and/or the defaults argument:
title.font.size - Plot title font size (UI: "Title Size", default: 26)
title.font.family - Font family for title text (UI: "Title Font", default: "Arial")
title.font.color - Color for plot title (UI: "Title Color", default: "#000000")
labels - Label column (UI: "Label column (summary data)", default: 2nd categorical column)
values - Aggregated value column (UI: "Aggregated value column", default: 2nd numeric column)
sort - Sort slices by value (UI: "Sort slices by value", default: TRUE)
direction - Slice direction (UI: "Slice direction", default: "counterclockwise")
rotation - Start angle in degrees (UI: "Start angle (degrees)", default: 0)
hole - Center hole size for donut chart (UI: "Center hole size", default: 0)
colors - Slice colors (UI: color picker, derived from palette)
slice.line.color - Slice border color (UI: "Slice border color", default: "#FFFFFF")
slice.line.width - Slice border width (UI: "Slice border width", default: 0)
textinfo - Text to show on slices (UI: "Text to show on slices", default: c("label", "value", "percent"))
textposition - Text position (UI: "Text position", default: "auto")
insidetextorientation - Inside text orientation (UI: "Inside text orientation", default: "auto")
text.font.size - Slice text size (UI: "Slice text size", default: 12)
text.font.family - Slice text font (UI: "Slice text font", default: "Arial")
text.font.color - Slice text color (UI: "Slice text color", default: "#000000")
title.x - Title horizontal position (UI: "Title horizontal position", default: 0.5)
show.legend - Show legend (UI: "Show legend", default: TRUE)
legend.orientation - Legend orientation (UI: "Legend orientation", default: "h")
legend.font.family - Legend font (UI: "Legend font", default: "Arial")
legend.font.size - Legend font size (UI: "Legend font size", default: 12)
legend.font.color - Legend font color (UI: "Legend font color", default: "#000000")
Jacob Martin, Jared Andrews
piePlot(), organize_inputs(),
piePlotOutputUI(), piePlotServer(), piePlotApp()
library(VizModules) pie_df <- as.data.frame(table(iris$Species)) names(pie_df) <- c("Species", "Count") piePlotInputsUI("piePlot", pie_df)library(VizModules) pie_df <- as.data.frame(table(iris$Species)) names(pie_df) <- c("Species", "Count") piePlotInputsUI("piePlot", pie_df)
This should be placed in the UI where the plot should be shown.
piePlotOutputUI(id)piePlotOutputUI(id)
id |
The ID for the Shiny module. |
A Shiny plotlyOutput for the piePlot
Jacob Martin, Jared Andrews
Server logic for piePlot module
piePlotServer(id, data, hide.inputs = NULL, hide.tabs = NULL, defaults = NULL)piePlotServer(id, data, hide.inputs = NULL, hide.tabs = NULL, defaults = NULL)
id |
The ID for the Shiny module. |
data |
A |
hide.inputs |
A character vector of input IDs to hide. These will still be initialized and their values passed to the plot function, but the user will not be able to see/adjust them in the UI. |
hide.tabs |
A character vector of tab names to hide. Inputs in these tabs will still be initialized and their values passed to the plot function, but the user will not be able to see/adjust them in the UI. |
defaults |
A named list of default values for the inputs. When the reset button is clicked, inputs are reset to these values rather than hardcoded fallbacks. Typically the same list passed to the corresponding UI function. |
The moduleServer function for the piePlot module.
Jacob Martin, Jared Andrews
piePlot(), piePlotInputsUI(),
piePlotOutputUI(), piePlotApp()
This function generates a Shiny application with modular plotthis::AreaPlot() components.
The app features a Data Import section for uploading data,
a Data Table for filtering the active dataset, and a Plot area
for configuring and displaying an interactive area plot.
plotthis_AreaPlotApp(data_list = NULL)plotthis_AreaPlotApp(data_list = NULL)
data_list |
An optional named list of data frames. If |
When data_list is not provided (or NULL), the app launches with
example_sales as an example dataset. Uploaded data files are added
to the available datasets and can be selected for plotting. If an uploaded
file shares a name with an existing dataset, the existing one is overwritten
with a warning.
This is a convenience wrapper around createModuleApp().
A Shiny app object.
Jacob Martin, Jared Andrews
library(VizModules) # Launch with default example data: app <- plotthis_AreaPlotApp() if (interactive()) runApp(app) # Launch with custom data: app2 <- plotthis_AreaPlotApp(list("sales" = example_sales)) if (interactive()) runApp(app2)library(VizModules) # Launch with default example data: app <- plotthis_AreaPlotApp() if (interactive()) runApp(app) # Launch with custom data: app2 <- plotthis_AreaPlotApp(list("sales" = example_sales)) if (interactive()) runApp(app2)
This should be placed in the UI where the inputs should be shown, with an id
that matches the id used in the plotthis_AreaPlotServer() and plotthis_AreaPlotOutputUI() functions.
plotthis_AreaPlotInputsUI(id, data, defaults = NULL, title = NULL, columns = 2)plotthis_AreaPlotInputsUI(id, data, defaults = NULL, title = NULL, columns = 2)
id |
The ID for the Shiny module. |
data |
The data frame used for plot generation. |
defaults |
A named list of default values for the inputs. |
title |
An optional title for the UI grid. |
columns |
Number of columns for the UI grid. |
The user inputs for this module are separated from the outputs to allow for more flexible UI design.
The inputs will automatically be organized into a grid layout via the organize_inputs() function,
with columns controlling the number of columns in the grid.
Defaults can be set for each input by providing a named list of values to the defaults argument.
Nearly all parameters for plotthis::AreaPlot() can be set via these inputs, so see the help
for that function for an exhaustive list.
A Shiny tagList containing the UI elements
The following plotthis::AreaPlot() parameters are not available via UI inputs:
xlab - X-axis label (plotly allows interactive editing)
ylab - Y-axis label (plotly allows interactive editing)
title - Plot title (plotly allows interactive editing)
subtitle - Plot subtitle (not supported in plotly)
aspect.ratio - Aspect ratio control (handled by plotly layout)
legend.position - Legend positioning (plotly allows interactive repositioning)
split_by - Split variable (returns a patchwork object, not supported in plotly), use facet_by instead
design - Only applies if split_by is used
split_by_sep - Only applies if split_by is used
axes - Only applies if split_by is used
axis_titles - Only applies if split_by is used
guides - Only applies if split_by is used
byrow - Only applies if split_by is used
nrow - Only applies if split_by is used
ncol - Only applies if split_by is used
palette - Managed internally via the palette selection UI
legend_direction - Managed position of legend however this can be handled via plotly
The following plotthis::AreaPlot() parameters can be accessed via UI inputs and/or the defaults argument:
x - X-axis variable (UI: "X values", default: 2nd categorical variable)
y - Y-axis variable (UI: "Y values", default: 2nd numeric variable)
group_by - Grouping variable for area fill (UI: "Group by", default: 3rd categorical variable or "")
facet_by - Faceting variable (UI: "Facet by", default: "")
facet_scales - Facet scale behavior (UI: "Facet scale", default: "fixed")
facet_ncol - Number of facet columns (UI: "Facet number of columns", default: NULL)
facet_nrow - Number of facet rows (UI: "Facet number of rows", default: NULL)
facet_byrow - Facet ordering direction (UI: "Facet by row", default: TRUE)
palcolor - Custom color values (UI: palette picker, derived from palette)
alpha - Area fill transparency (UI: "Alpha", default: 1)
scale_y - Scale y-axis by total (UI: "Scale y-axis by total", default: FALSE)
The following parameters implementing new functionality or controlling plotly-specific features are also available:
title.font.size - Plot title font size (UI: "Title Size", default: 26)
title.font.family - Font family for title text (UI: "Title Font", default: "Arial")
title.font.color - Color for plot title (UI: "Title Color", default: "#000000")
axis.title.font.size - Axis title font size (UI: "Axis Title Size", default: 18)
axis.title.font.color - Axis title font color (UI: "Axis Title Color", default: "#000000")
axis.title.font.family - Axis title font family (UI: "Axis Title Font", default: "Arial")
axis.showline - Show axis border lines (UI: "Show axis lines", default: TRUE)
axis.mirror - Mirror axis lines on opposite side (UI: "Mirror axis lines", default: TRUE)
show.grid.x - Show X-axis major gridlines (UI: "Show X major gridlines", default: TRUE)
show.grid.y - Show Y-axis major gridlines (UI: "Show Y major gridlines", default: TRUE)
axis.linecolor - Color of axis lines (UI: "Axis line color", default: "black")
axis.linewidth - Width of axis lines (UI: "Axis line width", default: 0.5)
axis.tickfont.size - Size of tick labels (UI: "Tick label size", default: 12)
axis.tickfont.color - Color of tick labels (UI: "Tick label color", default: "black")
axis.tickfont.family - Font family for tick labels (UI: "Tick label font", default: "Arial")
axis.tickangle.x - Rotation angle for X-axis tick labels (UI: "X-axis tick label angle", default: 0)
axis.tickangle.y - Rotation angle for Y-axis tick labels (UI: "Y-axis tick label angle", default: 0)
axis.ticks - Position of tick marks (UI: "Tick position", default: "outside")
axis.tickcolor - Color of tick marks (UI: "Tick mark color", default: "black")
axis.ticklen - Length of tick marks (UI: "Tick mark length", default: 5)
axis.tickwidth - Width of tick marks (UI: "Tick mark width", default: 1)
hline.intercepts - Y-coordinates for horizontal reference lines (UI: "Y-intercepts", default: "")
hline.colors - Colors for horizontal lines (UI: "Colors", default: "#000000")
hline.widths - Widths for horizontal lines (UI: "Widths", default: "1")
hline.linetypes - Line types for horizontal lines (UI: "Line types", default: "dashed")
hline.opacities - Opacities for horizontal lines (UI: "Opacities (0-1)", default: "1")
vline.intercepts - X-coordinates for vertical reference lines (UI: "X-intercepts", default: "")
vline.colors - Colors for vertical lines (UI: "Colors", default: "#000000")
vline.widths - Widths for vertical lines (UI: "Widths", default: "1")
vline.linetypes - Line types for vertical lines (UI: "Line types", default: "dashed")
vline.opacities - Opacities for vertical lines (UI: "Opacities (0-1)", default: "1")
abline.slopes - Slopes for diagonal reference lines (UI: "Slopes", default: "")
abline.intercepts - Y-intercepts for diagonal lines (UI: "Y-intercepts", default: "")
abline.colors - Colors for diagonal lines (UI: "Colors", default: "#000000")
abline.widths - Widths for diagonal lines (UI: "Widths", default: "1")
abline.linetypes - Line types for diagonal lines (UI: "Line types", default: "dashed")
abline.opacities - Opacities for diagonal lines (UI: "Opacities (0-1)", default: "1")
Jacob Martin, Jared Andrews
plotthis::AreaPlot(), organize_inputs(),
plotthis_AreaPlotOutputUI(), plotthis_AreaPlotServer(), plotthis_AreaPlotApp()
library(VizModules) # Needs at least 2 categorical variables for grouping and x-axis mtcars$cyl <- as.factor(mtcars$cyl) mtcars$gear <- as.factor(mtcars$gear) plotthis_AreaPlotInputsUI("areaPlot", mtcars)library(VizModules) # Needs at least 2 categorical variables for grouping and x-axis mtcars$cyl <- as.factor(mtcars$cyl) mtcars$gear <- as.factor(mtcars$gear) plotthis_AreaPlotInputsUI("areaPlot", mtcars)
This should be placed in the UI where the plot should be shown.
plotthis_AreaPlotOutputUI(id)plotthis_AreaPlotOutputUI(id)
id |
The ID for the Shiny module. |
A Shiny plotlyOutput for the AreaPlot
Jacob Martin
Server logic for AreaPlot module
plotthis_AreaPlotServer( id, data, hide.inputs = NULL, hide.tabs = NULL, defaults = NULL )plotthis_AreaPlotServer( id, data, hide.inputs = NULL, hide.tabs = NULL, defaults = NULL )
id |
The ID for the Shiny module. |
data |
A |
hide.inputs |
A character vector of input IDs to hide. These will still be initialized and their values passed to the plot function, but the user will not be able to see/adjust them in the UI. |
hide.tabs |
A character vector of tab names to hide. Inputs in these tabs will still be initialized and their values passed to the plot function, but the user will not be able to see/adjust them in the UI. |
defaults |
A named list of default values for the inputs. When the reset button is clicked, inputs are reset to these values rather than hardcoded fallbacks. Typically the same list passed to the corresponding UI function. |
The moduleServer function for the AreaPlot module.
Jacob Martin, Jared Andrews
This function generates a Shiny application with modular plotthis::BarPlot() components.
The app features a Data Import section for uploading data,
a Data Table for filtering the active dataset, and a Plot area
for configuring and displaying an interactive bar plot.
plotthis_BarPlotApp(data_list = NULL)plotthis_BarPlotApp(data_list = NULL)
data_list |
An optional named list of data frames. If |
When data_list is not provided (or NULL), the app launches with
example_bar as an example dataset. Uploaded data files are added
to the available datasets and can be selected for plotting. If an uploaded
file shares a name with an existing dataset, the existing one is overwritten
with a warning.
This is a convenience wrapper around createModuleApp().
A Shiny app object.
Jacob Martin, Jared Andrews
library(VizModules) # Launch with default example data: app <- plotthis_BarPlotApp() if (interactive()) runApp(app) # Launch with custom data: app2 <- plotthis_BarPlotApp(list("Bar" = example_bar)) if (interactive()) runApp(app2)library(VizModules) # Launch with default example data: app <- plotthis_BarPlotApp() if (interactive()) runApp(app) # Launch with custom data: app2 <- plotthis_BarPlotApp(list("Bar" = example_bar)) if (interactive()) runApp(app2)
This should be placed in the UI where the inputs should be shown, with an id
that matches the id used in the plotthis_BarPlotServer() and plotthis_BarPlotOutputUI() functions.
plotthis_BarPlotInputsUI(id, data, defaults = NULL, title = NULL, columns = 2)plotthis_BarPlotInputsUI(id, data, defaults = NULL, title = NULL, columns = 2)
id |
The ID for the Shiny module. |
data |
The data frame used for plot generation. |
defaults |
A named list of default values for the inputs. |
title |
An optional title for the UI grid. |
columns |
Number of columns for the UI grid. |
The user inputs for this module are separated from the outputs to allow for more flexible UI design.
The inputs will automatically be organized into a grid layout via the organize_inputs() function,
with columns controlling the number of columns in the grid.
Defaults can be set for each input by providing a named list of values to the defaults argument.
Nearly all parameters for plotthis::BarPlot() can be set via these inputs, so see the help
for that function for an exhaustive list.
A Shiny tagList containing the UI elements
The following plotthis::BarPlot() parameters are not available via UI inputs:
xlab - X-axis label (plotly allows interactive editing)
ylab - Y-axis label (plotly allows interactive editing)
title - Plot title (plotly allows interactive editing)
subtitle - Plot subtitle (not supported in plotly)
aspect.ratio - Aspect ratio control (handled by plotly layout)
legend.position - Legend positioning (plotly allows interactive repositioning)
position - Bar position (auto, stack, dodge, fill) (not yet implemented)
position_dodge_preserve - Preserve bar width when dodging (not yet implemented)
x_sep - Separator for multiple x columns (not yet implemented)
group_by_sep - Separator for multiple group_by columns (not yet implemented)
split_by_sep - Separator for multiple split_by columns (not yet implemented)
flip - Flip axes (not yet implemented)
fill_by_x_if_no_group - Fill bars by x values (not yet implemented)
line_name - Name of line (not yet implemented)
label - Bar labels on top (not yet implemented)
label_nudge - Label nudge distance (not yet implemented)
label_fg - Label foreground color (not yet implemented)
label_size - Label size (not yet implemented)
label_bg - Label background color (not yet implemented)
label_bg_r - Label background radius (not yet implemented)
group_name - Group legend name (not yet implemented)
facet_args - Additional facet arguments (not yet implemented)
add_bg - Add background stripes (not yet implemented)
bg_palette - Background palette (not yet implemented)
bg_palcolor - Background palette colors (not yet implemented)
bg_alpha - Background alpha (not yet implemented)
add_line - Add horizontal line (not yet implemented)
line_color - Horizontal line color (not yet implemented)
line_width - Horizontal line width (not yet implemented)
line_type - Horizontal line type (not yet implemented)
add_trend - Add trend line (not yet implemented)
trend_color - Trend line color (not yet implemented)
trend_linewidth - Trend line width (not yet implemented)
trend_ptsize - Trend point size (not yet implemented)
theme - ggplot2 theme (managed internally)
theme_args - Theme arguments (not yet implemented)
palette - Managed internally via the palette selection UI
x_text_angle - X-axis text angle (handled by axis.tickangle.x)
legend.direction - Legend orientation (plotly allows interactive adjustment)
keep_empty - Keep empty factor levels (not yet implemented)
keep_na - Keep NA values (not yet implemented)
combine - Combine multiple plots (not applicable for plotly)
nrow - Only applies if split_by is used with combine
ncol - Only applies if split_by is used with combine
byrow - Only applies if split_by is used with combine
seed - Random seed (not applicable)
axes - Only applies if split_by is used with combine
axis_titles - Only applies if split_by is used with combine
guides - Only applies if split_by is used with combine
design - Only applies if split_by is used with combine
The following plotthis::BarPlot() parameters can be accessed via UI inputs and/or the defaults argument:
x - X-axis variable (UI: "X values", default: 2nd categorical variable)
y - Y-axis variable (UI: "Y values", default: 2nd numeric variable)
group_by - Grouping variable for bar fill (UI: "Group by", default: 2nd categorical variable)
split_by - Split variable for separate plots (UI: "Split by", default: "")
facet_by - Faceting variable (UI: "Facet by", default: "")
facet_scales - Facet scale behavior (UI: "Facet scale", default: "fixed")
facet_ncol - Number of facet columns (UI: "Facet number of columns", default: NULL)
facet_nrow - Number of facet rows (UI: "Facet number of rows", default: NULL)
facet_byrow - Facet ordering direction (UI: "Facet by row", default: TRUE)
palcolor - Custom color values (UI: palette picker, derived from palette)
alpha - Bar fill transparency (UI: "Alpha", default: 1)
width - Bar width (UI: "Width", default: NA)
expand - Axis expansion values (UI: "Expand", default: "")
y_min - Y-axis minimum value (UI: "Y-axis min", default: 0)
y_max - Y-axis maximum value (UI: "Y-axis max", default: max of data)
The following parameters implementing new functionality or controlling plotly-specific features are also available:
title.font.size - Plot title font size (UI: "Title Size", default: 26)
title.font.family - Font family for title text (UI: "Title Font", default: "Arial")
title.font.color - Color for plot title (UI: "Title Color", default: "#000000")
axis.title.font.size - Axis title font size (UI: "Axis Title Size", default: 18)
axis.title.font.color - Axis title font color (UI: "Axis Title Color", default: "#000000")
axis.title.font.family - Axis title font family (UI: "Axis Title Font", default: "Arial")
axis.showline - Show axis border lines (UI: "Show axis lines", default: TRUE)
axis.mirror - Mirror axis lines on opposite side (UI: "Mirror axis lines", default: TRUE)
show.grid.x - Show X-axis major gridlines (UI: "Show X major gridlines", default: TRUE)
show.grid.y - Show Y-axis major gridlines (UI: "Show Y major gridlines", default: TRUE)
axis.linecolor - Color of axis lines (UI: "Axis line color", default: "black")
axis.linewidth - Width of axis lines (UI: "Axis line width", default: 0.5)
axis.tickfont.size - Size of tick labels (UI: "Tick label size", default: 12)
axis.tickfont.color - Color of tick labels (UI: "Tick label color", default: "black")
axis.tickfont.family - Font family for tick labels (UI: "Tick label font", default: "Arial")
axis.tickangle.x - Rotation angle for X-axis tick labels (UI: "X-axis tick label angle", default: 0)
axis.tickangle.y - Rotation angle for Y-axis tick labels (UI: "Y-axis tick label angle", default: 0)
axis.ticks - Position of tick marks (UI: "Tick position", default: "outside")
axis.tickcolor - Color of tick marks (UI: "Tick mark color", default: "black")
axis.ticklen - Length of tick marks (UI: "Tick mark length", default: 5)
axis.tickwidth - Width of tick marks (UI: "Tick mark width", default: 1)
hline.intercepts - Y-coordinates for horizontal reference lines (UI: "Y-intercepts", default: "")
hline.colors - Colors for horizontal lines (UI: "Colors", default: "#000000")
hline.widths - Widths for horizontal lines (UI: "Widths", default: "1")
hline.linetypes - Line types for horizontal lines (UI: "Line types", default: "dashed")
hline.opacities - Opacities for horizontal lines (UI: "Opacities (0-1)", default: "1")
vline.intercepts - X-coordinates for vertical reference lines (UI: "X-intercepts", default: "")
vline.colors - Colors for vertical lines (UI: "Colors", default: "#000000")
vline.widths - Widths for vertical lines (UI: "Widths", default: "1")
vline.linetypes - Line types for vertical lines (UI: "Line types", default: "dashed")
vline.opacities - Opacities for vertical lines (UI: "Opacities (0-1)", default: "1")
abline.slopes - Slopes for diagonal reference lines (UI: "Slopes", default: "")
abline.intercepts - Y-intercepts for diagonal lines (UI: "Y-intercepts", default: "")
abline.colors - Colors for diagonal lines (UI: "Colors", default: "#000000")
abline.widths - Widths for diagonal lines (UI: "Widths", default: "1")
abline.linetypes - Line types for diagonal lines (UI: "Line types", default: "dashed")
abline.opacities - Opacities for diagonal lines (UI: "Opacities (0-1)", default: "1")
Jacob Martin, Jared Andrews
plotthis::BarPlot(), organize_inputs(),
plotthis_BarPlotOutputUI(), plotthis_BarPlotServer(), plotthis_BarPlotApp()
library(VizModules) data(mtcars) plotthis_BarPlotInputsUI("BarPlot", mtcars)library(VizModules) data(mtcars) plotthis_BarPlotInputsUI("BarPlot", mtcars)
This should be placed in the UI where the plot should be shown.
plotthis_BarPlotOutputUI(id)plotthis_BarPlotOutputUI(id)
id |
The ID for the Shiny module. |
A Shiny plotlyOutput for the BarPlot
Jacob Martin, Jared Andrews
Server logic for BarPlot module
plotthis_BarPlotServer( id, data, hide.inputs = NULL, hide.tabs = NULL, defaults = NULL )plotthis_BarPlotServer( id, data, hide.inputs = NULL, hide.tabs = NULL, defaults = NULL )
id |
The ID for the Shiny module. |
data |
A |
hide.inputs |
A character vector of input IDs to hide. These will still be initialized and their values passed to the plot function, but the user will not be able to see/adjust them in the UI. |
hide.tabs |
A character vector of tab names to hide. Inputs in these tabs will still be initialized and their values passed to the plot function, but the user will not be able to see/adjust them in the UI. |
defaults |
A named list of default values for the inputs. When the reset button is clicked, inputs are reset to these values rather than hardcoded fallbacks. Typically the same list passed to the corresponding UI function. |
The moduleServer function for the BarPlot module.
Jacob Martin, Jared Andrews
This function generates a Shiny application with modular plotthis::BoxPlot() components.
The app features a Data Import section for uploading data,
a Data Table for filtering the active dataset, and a Plot area
for configuring and displaying an interactive box plot.
plotthis_BoxPlotApp(data_list = NULL)plotthis_BoxPlotApp(data_list = NULL)
data_list |
An optional named list of data frames. If |
When data_list is not provided (or NULL), the app launches with
example_demographics as an example dataset. Uploaded data files are added
to the available datasets and can be selected for plotting. If an uploaded
file shares a name with an existing dataset, the existing one is overwritten
with a warning.
This is a convenience wrapper around createModuleApp().
A Shiny app object.
Jacob Martin, Jared Andrews
library(VizModules) # Launch with default example data: app <- plotthis_BoxPlotApp() if (interactive()) runApp(app) # Launch with custom data: app2 <- plotthis_BoxPlotApp(list("demographics" = example_demographics)) if (interactive()) runApp(app2)library(VizModules) # Launch with default example data: app <- plotthis_BoxPlotApp() if (interactive()) runApp(app) # Launch with custom data: app2 <- plotthis_BoxPlotApp(list("demographics" = example_demographics)) if (interactive()) runApp(app2)
This should be placed in the UI where the inputs should be shown, with an id
that matches the id used in the plotthis_BoxPlotServer() and plotthis_BoxPlotOutputUI() functions.
plotthis_BoxPlotInputsUI(id, data, defaults = NULL, title = NULL, columns = 2)plotthis_BoxPlotInputsUI(id, data, defaults = NULL, title = NULL, columns = 2)
id |
The ID for the Shiny module. |
data |
The data frame used for plot generation. |
defaults |
A named list of default values for the inputs. |
title |
An optional title for the UI grid. |
columns |
Number of columns for the UI grid. |
The user inputs for this module are separated from the outputs to allow for more flexible UI design.
The inputs will automatically be organized into a grid layout via the organize_inputs() function,
with columns controlling the number of columns in the grid.
Defaults can be set for each input by providing a named list of values to the defaults argument.
Nearly all parameters for plotthis::BoxPlot() can be set via these inputs, so see the help
for that function for an exhaustive list.
A Shiny tagList containing the UI elements
The following plotthis::BoxPlot() parameters are not available via UI inputs:
xlab - X-axis label (plotly allows interactive editing)
ylab - Y-axis label (plotly allows interactive editing)
title - Plot title (plotly allows interactive editing)
subtitle - Plot subtitle (not supported in plotly)
aspect.ratio - Aspect ratio control (handled by plotly layout)
legend.position - Legend positioning (plotly allows interactive repositioning)
x_sep - Separator for x columns (not applicable in UI context)
in_form - Data input format (not applicable - always long form)
split_by - Split variable (returns a patchwork object, not supported in plotly), use facet_by instead
split_by_sep - Only applies if split_by is used
symnum_args - Significance symbol arguments (not implemented)
flip - Flip axes (not implemented in current UI)
keep_empty - Keep empty values (not implemented)
keep_na - Keep NA values (not implemented)
group_by_sep - Separator for group columns (not applicable in UI context)
group_name - Group legend name (handled by plotly)
paired_by - Pairing variable for paired tests (not implemented)
x_text_angle - X-axis text angle (handled by plotly axis settings)
step_increase - Step increase for significance brackets (not implemented)
fill_mode - Fill mode for grouped data (handled automatically)
fill_reverse - Reverse fill order (not implemented)
theme - ggplot2 theme (not applicable in plotly)
theme_args - Theme arguments (not applicable in plotly)
palette - Managed internally via the palette selection UI
alpha - Alpha transparency (not implemented in UI)
stack - Stack boxplots (not implemented)
add_beeswarm - Add beeswarm points (not implemented in UI)
beeswarm_method - Beeswarm arrangement method (not implemented)
beeswarm_cex - Beeswarm point size factor (not implemented)
beeswarm_priority - Beeswarm priority order (not implemented)
beeswarm_dodge - Beeswarm dodge width (not implemented)
add_trend - Add trend line (not implemented in UI)
trend_color - Trend line color (not implemented)
trend_linewidth - Trend line width (not implemented)
trend_ptsize - Trend point size (not implemented)
add_stat - Add statistical annotation (not implemented)
stat_name - Statistical test name (not implemented)
stat_color - Statistical annotation color (not implemented)
stat_size - Statistical annotation size (not implemented)
stat_stroke - Statistical annotation stroke (not implemented)
stat_shape - Statistical annotation shape (not implemented)
add_bg - Add background shading (not implemented)
bg_palette - Background palette (not implemented)
bg_palcolor - Background color (not implemented)
bg_alpha - Background transparency (not implemented)
add_line - Add horizontal line (not implemented in UI - use Lines tab)
line_color - Line color (not implemented)
line_width - Line width (not implemented)
line_type - Line type (not implemented)
comparisons - Group comparisons for significance tests (not implemented)
ref_group - Reference group for comparisons (not implemented)
pairwise_method - Pairwise test method (not implemented)
multiplegroup_comparisons - Multiple group comparison flag (not implemented)
multiple_method - Multiple group test method (not implemented)
sig_label - Significance label format (not implemented)
sig_labelsize - Significance label size (not implemented)
hide_ns - Hide non-significant comparisons (not implemented)
seed - Random seed (not applicable)
combine - Only applies if split_by is used
nrow - Only applies if split_by is used
ncol - Only applies if split_by is used
byrow - Only applies if split_by is used
axes - Only applies if split_by is used
axis_titles - Only applies if split_by is used
guides - Only applies if split_by is used
legend_direction - Managed position of legend however this can be handled via plotly
The following plotthis::BoxPlot() parameters can be accessed via UI inputs and/or the defaults argument:
x - X-axis variable (UI: "X data", default: 2nd categorical variable)
y - Y-axis variable (UI: "Y data", default: 2nd numeric variable)
group_by - Grouping variable (UI: "Group by", default: "")
sort_x - Sort X-axis by statistic (UI: "Sort X by", default: "")
y_max - Maximum Y-axis value (UI: "Max Value of Y Axis", default: calculated)
y_min - Minimum Y-axis value (UI: "Min Value of Y Axis", default: calculated)
add_point - Add jitter points (UI: "Add Jitter Points", default: FALSE)
pt_size - Point size (UI: "Point Size", default: 1)
pt_alpha - Point transparency (UI: "Point Alpha", default: 1)
jitter_width - Jitter width (UI: "Jitter Width", default: 0.3)
pt_color - Point outline color (UI: "Point Outline Colour", default: "#000000")
highlight - Highlight condition (UI: "Highlight", default: "")
highlight_color - Highlight color (UI: "Highlight Colour", default: "#000000")
highlight_size - Highlight size (UI: "Highlight Size", default: 1)
highlight_alpha - Highlight transparency (UI: "Highlight Alpha", default: 1)
facet_by - Faceting variable (UI: "Facet by", default: "")
facet_scales - Facet scale behavior (UI: "Facet Scale", default: "fixed")
facet_ncol - Number of facet columns (UI: "Columns", default: NULL)
facet_nrow - Number of facet rows (UI: "Rows", default: NULL)
facet_byrow - Facet ordering direction (UI: "Facet by Row", default: TRUE)
palcolor - Custom color values (UI: palette picker, derived from palette)
The following parameters implementing new functionality or controlling plotly-specific features are also available:
boxplot.width - Width of boxplot (UI: "Boxplot Width", default: 0.8)
show.outliers - Show outlier points (UI: "Show Outliers", default: TRUE)
axis.title.font.size - Axis title font size (UI: "Axis title size", default: 18)
title.font.size - Plot title font size (UI: "Title Size", default: 26)
title.font.family - Font family for title text (UI: "Title Font", default: "Arial")
title.font.color - Color for plot title (UI: "Title Color", default: "#000000")
axis.title.font.size - Axis title font size (UI: "Axis Title Size", default: 18)
axis.title.font.color - Axis title font color (UI: "Axis Title Color", default: "#000000")
axis.title.font.family - Axis title font family (UI: "Axis Title Font", default: "Arial")
axis.showline - Show axis border lines (UI: "Show axis lines", default: TRUE)
axis.mirror - Mirror axis lines on opposite side (UI: "Mirror axis lines", default: TRUE)
show.grid.x - Show X-axis major gridlines (UI: "Show X major gridlines", default: TRUE)
show.grid.y - Show Y-axis major gridlines (UI: "Show Y major gridlines", default: TRUE)
axis.linecolor - Color of axis lines (UI: "Axis line color", default: "black")
axis.linewidth - Width of axis lines (UI: "Axis line width", default: 0.5)
axis.tickfont.size - Size of tick labels (UI: "Tick label size", default: 12)
axis.tickfont.color - Color of tick labels (UI: "Tick label color", default: "black")
axis.tickfont.family - Font family for tick labels (UI: "Tick label font", default: "Arial")
axis.tickangle.x - Rotation angle for X-axis tick labels (UI: "X-axis tick label angle", default: 0)
axis.tickangle.y - Rotation angle for Y-axis tick labels (UI: "Y-axis tick label angle", default: 0)
axis.ticks - Position of tick marks (UI: "Tick position", default: "outside")
axis.tickcolor - Color of tick marks (UI: "Tick mark color", default: "black")
axis.ticklen - Length of tick marks (UI: "Tick mark length", default: 5)
axis.tickwidth - Width of tick marks (UI: "Tick mark width", default: 1)
hline.intercepts - Y-coordinates for horizontal reference lines (UI: "Y-intercepts", default: "")
hline.colors - Colors for horizontal lines (UI: "Colors", default: "#000000")
hline.widths - Widths for horizontal lines (UI: "Widths", default: "1")
hline.linetypes - Line types for horizontal lines (UI: "Line types", default: "dashed")
hline.opacities - Opacities for horizontal lines (UI: "Opacities (0-1)", default: "1")
vline.intercepts - X-coordinates for vertical reference lines (UI: "X-intercepts", default: "")
vline.colors - Colors for vertical lines (UI: "Colors", default: "#000000")
vline.widths - Widths for vertical lines (UI: "Widths", default: "1")
vline.linetypes - Line types for vertical lines (UI: "Line types", default: "dashed")
vline.opacities - Opacities for vertical lines (UI: "Opacities (0-1)", default: "1")
abline.slopes - Slopes for diagonal reference lines (UI: "Slopes", default: "")
abline.intercepts - Y-intercepts for diagonal lines (UI: "Y-intercepts", default: "")
abline.colors - Colors for diagonal lines (UI: "Colors", default: "#000000")
abline.widths - Widths for diagonal lines (UI: "Widths", default: "1")
abline.linetypes - Line types for diagonal lines (UI: "Line types", default: "dashed")
abline.opacities - Opacities for diagonal lines (UI: "Opacities (0-1)", default: "1")
Jacob Martin, Jared Andrews
plotthis::BoxPlot(), organize_inputs(),
plotthis_BoxPlotOutputUI(), plotthis_BoxPlotServer(),
plotthis_BoxPlotApp()
library(VizModules) data(mtcars) plotthis_BoxPlotInputsUI("BoxPlot", mtcars)library(VizModules) data(mtcars) plotthis_BoxPlotInputsUI("BoxPlot", mtcars)
This should be placed in the UI where the plot should be shown.
plotthis_BoxPlotOutputUI(id)plotthis_BoxPlotOutputUI(id)
id |
The ID for the Shiny module. |
A Shiny plotlyOutput for the boxPlot
Jacob Martin
Server logic for BoxPlot module
plotthis_BoxPlotServer( id, data, hide.inputs = NULL, hide.tabs = NULL, defaults = NULL )plotthis_BoxPlotServer( id, data, hide.inputs = NULL, hide.tabs = NULL, defaults = NULL )
id |
The ID for the Shiny module. |
data |
A |
hide.inputs |
A character vector of input IDs to hide. These will still be initialized and their values passed to the plot function, but the user will not be able to see/adjust them in the UI. |
hide.tabs |
A character vector of tab names to hide. Inputs in these tabs will still be initialized and their values passed to the plot function, but the user will not be able to see/adjust them in the UI. |
defaults |
A named list of default values for the inputs. When the reset button is clicked, inputs are reset to these values rather than hardcoded fallbacks. Typically the same list passed to the corresponding UI function. |
The moduleServer function for the BoxPlot module.
Jacob Martin, Jared Andrews
This function generates a Shiny application with modular density plot components. The app features a Data Import section for uploading data, a Data Table for filtering the active dataset, and a Plot area for configuring and displaying an interactive density plot.
plotthis_DensityPlotApp(data_list = NULL)plotthis_DensityPlotApp(data_list = NULL)
data_list |
An optional named list of data frames. If |
When data_list is not provided (or NULL), the app launches with
example_demographics as an example dataset. Uploaded data files are added
to the available datasets and can be selected for plotting. If an uploaded
file shares a name with an existing dataset, the existing one is overwritten
with a warning.
This is a convenience wrapper around createModuleApp().
A Shiny app object.
Jacob Martin, Jared Andrews
library(VizModules) # Launch with default example data: app <- plotthis_DensityPlotApp() if (interactive()) runApp(app) # Launch with custom data: app2 <- plotthis_DensityPlotApp(list("demographics" = example_demographics)) if (interactive()) runApp(app2)library(VizModules) # Launch with default example data: app <- plotthis_DensityPlotApp() if (interactive()) runApp(app) # Launch with custom data: app2 <- plotthis_DensityPlotApp(list("demographics" = example_demographics)) if (interactive()) runApp(app2)
This should be placed in the UI where the inputs should be shown, with an id
that matches the id used in the plotthis_DensityPlotServer() and plotthis_DensityPlotOutputUI() functions.
plotthis_DensityPlotInputsUI( id, data, defaults = NULL, title = NULL, columns = 2 )plotthis_DensityPlotInputsUI( id, data, defaults = NULL, title = NULL, columns = 2 )
id |
The ID for the Shiny module. |
data |
The data frame used for plot generation. |
defaults |
A named list of default values for the inputs. |
title |
An optional title for the UI grid. |
columns |
Number of columns for the UI grid. |
The user inputs for this module are separated from the outputs to allow for more flexible UI design.
The inputs will automatically be organized into a grid layout via the organize_inputs() function,
with columns controlling the number of columns in the grid.
Defaults can be set for each input by providing a named list of values to the defaults argument.
Nearly all parameters for plotthis::DensityPlot() can be set via these inputs, so see the help
for that function for an exhaustive list.
A Shiny tagList containing the UI elements
The following plotthis::DensityPlot() parameters are not available via UI inputs:
xlab - X-axis label (plotly allows interactive editing)
ylab - Y-axis label (plotly allows interactive editing)
title - Plot title (plotly allows interactive editing)
subtitle - Plot subtitle (not supported in plotly)
legend.position - Legend positioning (plotly allows interactive repositioning)
group_by_sep - Separator for group columns (not applicable in UI context)
group_name - Group legend name (handled by plotly)
xtrans - X-axis transformation (not implemented in UI)
ytrans - Y-axis transformation (not implemented in UI)
split_by - Split variable (returns a patchwork object, not supported in plotly), use facet_by instead
split_by_sep - Only applies if split_by is used
flip - Flip axes (not implemented in current UI)
theme - ggplot2 theme (not applicable in plotly)
theme_args - Theme arguments (not applicable in plotly)
palette - Managed internally via the palette selection UI
expand - Axis expansion (not implemented)
seed - Random seed (not applicable)
combine - Only applies if split_by is used
nrow - Only applies if split_by is used
ncol - Only applies if split_by is used
byrow - Only applies if split_by is used
axes - Only applies if split_by is used
axis_titles - Only applies if split_by is used
guides - Only applies if split_by is used
design - Only applies if split_by is used
legend_direction - Managed position of legend however this can be handled via plotly
The following plotthis::DensityPlot() parameters can be accessed via UI inputs and/or the defaults argument:
x - X-axis variable (UI: "X Data", default: 2nd numeric variable)
group_by - Grouping variable (UI: "Group By", default: "")
position - Position adjustment (UI: "Position", default: "identity")
alpha - Density fill transparency (UI: "Plot Alpha", default: 0.5)
add_bars - Add rug plot (UI: "Add Rug Plot", default: FALSE)
bar_height - Rug bar height (UI: "Rug Bar Height", default: 0.04)
bar_alpha - Rug bar transparency (UI: "Rug Bar Alpha", default: 1)
bar_width - Rug bar width (UI: "Rug Bar Width", default: 1)
facet_by - Faceting variable (UI: "Facet By", default: "")
facet_scales - Facet scale behavior (UI: "Facet Scale", default: "fixed")
facet_ncol - Number of facet columns (UI: "Number of Columns", default: NULL)
facet_nrow - Number of facet rows (UI: "Number of Rows", default: NULL)
facet_byrow - Facet ordering direction (UI: "Facet by Row", default: TRUE)
palcolor - Custom color values (UI: palette picker, derived from palette)
The following parameters implementing new functionality or controlling plotly-specific features are also available:
title.font.size - Plot title font size (UI: "Title Size", default: 26)
title.font.family - Font family for title text (UI: "Title Font", default: "Arial")
title.font.color - Color for plot title (UI: "Title Color", default: "#000000")
axis.title.font.size - Axis title font size (UI: "Axis Title Size", default: 18)
axis.title.font.color - Axis title font color (UI: "Axis Title Color", default: "#000000")
axis.title.font.family - Axis title font family (UI: "Axis Title Font", default: "Arial")
axis.showline - Show axis border lines (UI: "Show axis lines", default: TRUE)
axis.mirror - Mirror axis lines on opposite side (UI: "Mirror axis lines", default: TRUE)
show.grid.x - Show X-axis major gridlines (UI: "Show X major gridlines", default: TRUE)
show.grid.y - Show Y-axis major gridlines (UI: "Show Y major gridlines", default: TRUE)
axis.linecolor - Color of axis lines (UI: "Axis line color", default: "black")
axis.linewidth - Width of axis lines (UI: "Axis line width", default: 0.5)
axis.tickfont.size - Size of tick labels (UI: "Tick label size", default: 12)
axis.tickfont.color - Color of tick labels (UI: "Tick label color", default: "black")
axis.tickfont.family - Font family for tick labels (UI: "Tick label font", default: "Arial")
axis.tickangle.x - Rotation angle for X-axis tick labels (UI: "X-axis tick label angle", default: 0)
axis.tickangle.y - Rotation angle for Y-axis tick labels (UI: "Y-axis tick label angle", default: 0)
axis.ticks - Position of tick marks (UI: "Tick position", default: "outside")
axis.tickcolor - Color of tick marks (UI: "Tick mark color", default: "black")
axis.ticklen - Length of tick marks (UI: "Tick mark length", default: 5)
axis.tickwidth - Width of tick marks (UI: "Tick mark width", default: 1)
hline.intercepts - Y-coordinates for horizontal reference lines (UI: "Y-intercepts", default: "")
hline.colors - Colors for horizontal lines (UI: "Colors", default: "#000000")
hline.widths - Widths for horizontal lines (UI: "Widths", default: "1")
hline.linetypes - Line types for horizontal lines (UI: "Line types", default: "dashed")
hline.opacities - Opacities for horizontal lines (UI: "Opacities (0-1)", default: "1")
vline.intercepts - X-coordinates for vertical reference lines (UI: "X-intercepts", default: "")
vline.colors - Colors for vertical lines (UI: "Colors", default: "#000000")
vline.widths - Widths for vertical lines (UI: "Widths", default: "1")
vline.linetypes - Line types for vertical lines (UI: "Line types", default: "dashed")
vline.opacities - Opacities for vertical lines (UI: "Opacities (0-1)", default: "1")
abline.slopes - Slopes for diagonal reference lines (UI: "Slopes", default: "")
abline.intercepts - Y-intercepts for diagonal lines (UI: "Y-intercepts", default: "")
abline.colors - Colors for diagonal lines (UI: "Colors", default: "#000000")
abline.widths - Widths for diagonal lines (UI: "Widths", default: "1")
abline.linetypes - Line types for diagonal lines (UI: "Line types", default: "dashed")
abline.opacities - Opacities for diagonal lines (UI: "Opacities (0-1)", default: "1")
Jacob Martin, Jared Andrews
plotthis::DensityPlot(), organize_inputs(),
plotthis_DensityPlotOutputUI(), plotthis_DensityPlotServer(), plotthis_DensityPlotApp()
library(VizModules) data(mtcars) plotthis_DensityPlotInputsUI("densityPlot", mtcars)library(VizModules) data(mtcars) plotthis_DensityPlotInputsUI("densityPlot", mtcars)
This should be placed in the UI where the plot should be shown.
plotthis_DensityPlotOutputUI(id)plotthis_DensityPlotOutputUI(id)
id |
The ID for the Shiny module. |
A Shiny plotlyOutput for the DensityPlot
Jacob Martin
Server-side logic for the density plot module. This function manages reactive data processing, dynamic UI generation for color palettes, and the rendering of interactive Plotly density plots.
plotthis_DensityPlotServer( id, data, hide.inputs = NULL, hide.tabs = NULL, defaults = NULL )plotthis_DensityPlotServer( id, data, hide.inputs = NULL, hide.tabs = NULL, defaults = NULL )
id |
|
data |
|
hide.inputs |
|
hide.tabs |
|
defaults |
A named list of default values for the inputs. When the reset button is clicked, inputs are reset to these values rather than hardcoded fallbacks. Typically the same list passed to the corresponding UI function. |
The moduleServer function for the DensityPlot module.
Jacob Martin, Jared Andrews
This function generates a Shiny application with modular histogram components. The app features a Data Import section for uploading data, a Data Table for filtering the active dataset, and a Plot area for configuring and displaying an interactive histogram.
plotthis_HistogramApp(data_list = NULL)plotthis_HistogramApp(data_list = NULL)
data_list |
An optional named list of data frames. If |
When data_list is not provided (or NULL), the app launches with
example_demographics as an example dataset. Uploaded data files are added
to the available datasets and can be selected for plotting. If an uploaded
file shares a name with an existing dataset, the existing one is overwritten
with a warning.
This is a convenience wrapper around createModuleApp().
A Shiny app object.
Jacob Martin, Jared Andrews
library(VizModules) # Launch with default example data: app <- plotthis_HistogramApp() if (interactive()) runApp(app) # Launch with custom data: app2 <- plotthis_HistogramApp(list("demographics" = example_demographics)) if (interactive()) runApp(app2)library(VizModules) # Launch with default example data: app <- plotthis_HistogramApp() if (interactive()) runApp(app) # Launch with custom data: app2 <- plotthis_HistogramApp(list("demographics" = example_demographics)) if (interactive()) runApp(app2)
This should be placed in the UI where the inputs should be shown, with an id
that matches the id used in the plotthis_HistogramServer() and plotthis_HistogramOutputUI() functions.
plotthis_HistogramInputsUI( id, data, defaults = NULL, title = NULL, columns = 2 )plotthis_HistogramInputsUI( id, data, defaults = NULL, title = NULL, columns = 2 )
id |
The ID for the Shiny module. |
data |
The data frame used for plot generation. |
defaults |
A named list of default values for the inputs. |
title |
An optional title for the UI grid. |
columns |
Number of columns for the UI grid. |
The user inputs for this module are separated from the outputs to allow for more flexible UI design.
The inputs will automatically be organized into a grid layout via the organize_inputs() function,
with columns controlling the number of columns in the grid.
Defaults can be set for each input by providing a named list of values to the defaults argument.
Nearly all parameters for plotthis::Histogram() can be set via these inputs, so see the help
for that function for an exhaustive list.
A Shiny tagList containing the UI elements
The following plotthis::Histogram() parameters are not available via UI inputs:
xlab - X-axis label (plotly allows interactive editing)
ylab - Y-axis label (plotly allows interactive editing)
title - Plot title (plotly allows interactive editing)
subtitle - Plot subtitle (not supported in plotly)
legend.position - Legend positioning (plotly allows interactive repositioning)
group_by_sep - Separator for group columns (not applicable in UI context)
group_name - Group legend name (handled by plotly)
xtrans - X-axis transformation (not implemented in UI)
ytrans - Y-axis transformation (not implemented in UI)
split_by - Split variable (returns a patchwork object, not supported in plotly), use facet_by instead
split_by_sep - Only applies if split_by is used
flip - Flip axes (not implemented in current UI)
theme - ggplot2 theme (not applicable in plotly)
theme_args - Theme arguments (not applicable in plotly)
palette - Managed internally via the palette selection UI
expand - Axis expansion (not implemented)
seed - Random seed (not applicable)
combine - Only applies if split_by is used
nrow - Only applies if split_by is used
ncol - Only applies if split_by is used
byrow - Only applies if split_by is used
axes - Only applies if split_by is used
axis_titles - Only applies if split_by is used
guides - Only applies if split_by is used
design - Only applies if split_by is used
legend_direction - Managed position of legend however this can be handled via plotly
The following plotthis::Histogram() parameters can be accessed via UI inputs and/or the defaults argument:
x - X-axis variable (UI: "X Data", default: 2nd numeric variable)
group_by - Grouping variable (UI: "Group By", default: "")
bins - Number of bins (UI: "Number of Bins", default: NA)
binwidth - Width of bins (UI: "Bin Width", default: NA)
use_trend - Show only trend line (UI: "Trend Line Only", default: FALSE)
add_trend - Add trend line to histogram (UI: "Add Trend to Histogram", default: FALSE)
trend_skip_zero - Skip zero values in trend (UI: "Skip Zero Values", default: FALSE)
trend_alpha - Trend line transparency (UI: "Trend Line Alpha", default: 1)
trend_linewidth - Trend line width (UI: "Trend Line Width", default: 0.8)
trend_pt_size - Trend point size (UI: "Trend Point Size", default: 1.5)
position - Position adjustment (UI: "Position", default: "identity")
alpha - Histogram fill transparency (UI: "Plot Alpha", default: 1)
add_bars - Add rug plot (UI: "Add Rug Plot", default: FALSE)
bar_height - Rug bar height (UI: "Rug Bar Height", default: 0.04)
bar_alpha - Rug bar transparency (UI: "Rug Bar Alpha", default: 1)
bar_width - Rug bar width (UI: "Rug Bar Width", default: 1)
facet_by - Faceting variable (UI: "Facet By", default: "")
facet_scales - Facet scale behavior (UI: "Facet Scale", default: "fixed")
facet_ncol - Number of facet columns (UI: "Number of Columns", default: NULL)
facet_nrow - Number of facet rows (UI: "Number of Rows", default: NULL)
facet_byrow - Facet ordering direction (UI: "Facet by Row", default: TRUE)
palcolor - Custom color values (UI: palette picker, derived from palette)
The following parameters implementing new functionality or controlling plotly-specific features are also available:
title.font.size - Plot title font size (UI: "Title Size", default: 26)
title.font.family - Font family for title text (UI: "Title Font", default: "Arial")
title.font.color - Color for plot title (UI: "Title Color", default: "#000000")
axis.title.font.size - Axis title font size (UI: "Axis Title Size", default: 18)
axis.title.font.color - Axis title font color (UI: "Axis Title Color", default: "#000000")
axis.title.font.family - Axis title font family (UI: "Axis Title Font", default: "Arial")
axis.showline - Show axis border lines (UI: "Show axis lines", default: TRUE)
axis.mirror - Mirror axis lines on opposite side (UI: "Mirror axis lines", default: TRUE)
show.grid.x - Show X-axis major gridlines (UI: "Show X major gridlines", default: TRUE)
show.grid.y - Show Y-axis major gridlines (UI: "Show Y major gridlines", default: TRUE)
axis.linecolor - Color of axis lines (UI: "Axis line color", default: "black")
axis.linewidth - Width of axis lines (UI: "Axis line width", default: 0.5)
axis.tickfont.size - Size of tick labels (UI: "Tick label size", default: 12)
axis.tickfont.color - Color of tick labels (UI: "Tick label color", default: "black")
axis.tickfont.family - Font family for tick labels (UI: "Tick label font", default: "Arial")
axis.tickangle.x - Rotation angle for X-axis tick labels (UI: "X-axis tick label angle", default: 0)
axis.tickangle.y - Rotation angle for Y-axis tick labels (UI: "Y-axis tick label angle", default: 0)
axis.ticks - Position of tick marks (UI: "Tick position", default: "outside")
axis.tickcolor - Color of tick marks (UI: "Tick mark color", default: "black")
axis.ticklen - Length of tick marks (UI: "Tick mark length", default: 5)
axis.tickwidth - Width of tick marks (UI: "Tick mark width", default: 1)
hline.intercepts - Y-coordinates for horizontal reference lines (UI: "Y-intercepts", default: "")
hline.colors - Colors for horizontal lines (UI: "Colors", default: "#000000")
hline.widths - Widths for horizontal lines (UI: "Widths", default: "1")
hline.linetypes - Line types for horizontal lines (UI: "Line types", default: "dashed")
hline.opacities - Opacities for horizontal lines (UI: "Opacities (0-1)", default: "1")
vline.intercepts - X-coordinates for vertical reference lines (UI: "X-intercepts", default: "")
vline.colors - Colors for vertical lines (UI: "Colors", default: "#000000")
vline.widths - Widths for vertical lines (UI: "Widths", default: "1")
vline.linetypes - Line types for vertical lines (UI: "Line types", default: "dashed")
vline.opacities - Opacities for vertical lines (UI: "Opacities (0-1)", default: "1")
abline.slopes - Slopes for diagonal reference lines (UI: "Slopes", default: "")
abline.intercepts - Y-intercepts for diagonal lines (UI: "Y-intercepts", default: "")
abline.colors - Colors for diagonal lines (UI: "Colors", default: "#000000")
abline.widths - Widths for diagonal lines (UI: "Widths", default: "1")
abline.linetypes - Line types for diagonal lines (UI: "Line types", default: "dashed")
abline.opacities - Opacities for diagonal lines (UI: "Opacities (0-1)", default: "1")
Jacob Martin, Jared Andrews
plotthis::Histogram(), organize_inputs(),
plotthis_HistogramOutputUI(), plotthis_HistogramServer(), plotthis_HistogramApp()
library(VizModules) data(mtcars) plotthis_HistogramInputsUI("histogram", mtcars)library(VizModules) data(mtcars) plotthis_HistogramInputsUI("histogram", mtcars)
This should be placed in the UI where the plot should be shown.
plotthis_HistogramOutputUI(id)plotthis_HistogramOutputUI(id)
id |
The ID for the Shiny module. |
A Shiny plotlyOutput for the histogramPlot
Jacob Martin
Server-side logic for the histogram plot module. This function manages reactive data processing, dynamic UI generation for color palettes, and the rendering of interactive Plotly histograms.
plotthis_HistogramServer( id, data, hide.inputs = NULL, hide.tabs = NULL, defaults = NULL )plotthis_HistogramServer( id, data, hide.inputs = NULL, hide.tabs = NULL, defaults = NULL )
id |
|
data |
|
hide.inputs |
|
hide.tabs |
|
defaults |
A named list of default values for the inputs. When the reset button is clicked, inputs are reset to these values rather than hardcoded fallbacks. Typically the same list passed to the corresponding UI function. |
The moduleServer function for the Histogram module.
Jacob Martin, Jared Andrews
This function generates a Shiny application with modular plotthis::SplitBarPlot() components.
The app features a Data Import section for uploading data,
a Data Table for filtering the active dataset, and a Plot area
for configuring and displaying an interactive split bar plot.
plotthis_SplitBarPlotApp(data_list = NULL)plotthis_SplitBarPlotApp(data_list = NULL)
data_list |
An optional named list of data frames. If |
When data_list is not provided (or NULL), the app launches with
example_bar as an example dataset. Uploaded data files are added
to the available datasets and can be selected for plotting. If an uploaded
file shares a name with an existing dataset, the existing one is overwritten
with a warning.
This is a convenience wrapper around createModuleApp().
A Shiny app object.
Jacob Martin, Jared Andrews
library(VizModules) # Launch with default example data: app <- plotthis_SplitBarPlotApp() if (interactive()) runApp(app) # Launch with custom data: app2 <- plotthis_SplitBarPlotApp(list("Bar" = example_bar)) if (interactive()) runApp(app2)library(VizModules) # Launch with default example data: app <- plotthis_SplitBarPlotApp() if (interactive()) runApp(app) # Launch with custom data: app2 <- plotthis_SplitBarPlotApp(list("Bar" = example_bar)) if (interactive()) runApp(app2)
This should be placed in the UI where the inputs should be shown, with an id
that matches the id used in the plotthis_SplitBarPlotServer() and plotthis_SplitBarPlotOutputUI() functions.
plotthis_SplitBarPlotInputsUI( id, data, defaults = NULL, title = NULL, columns = 2 )plotthis_SplitBarPlotInputsUI( id, data, defaults = NULL, title = NULL, columns = 2 )
id |
The ID for the Shiny module. |
data |
The data frame used for plot generation. |
defaults |
A named list of default values for the inputs. |
title |
An optional title for the UI grid. |
columns |
Number of columns for the UI grid. |
The user inputs for this module are separated from the outputs to allow for more flexible UI design.
The inputs will automatically be organized into a grid layout via the organize_inputs() function,
with columns controlling the number of columns in the grid.
Defaults can be set for each input by providing a named list of values to the defaults argument.
Nearly all parameters for plotthis::SplitBarPlot() can be set via these inputs, so see the help
for that function for an exhaustive list.
A Shiny tagList containing the UI elements
The following plotthis::SplitBarPlot() parameters are not available via UI inputs:
xlab - X-axis label (plotly allows interactive editing)
ylab - Y-axis label (plotly allows interactive editing)
title - Plot title (plotly allows interactive editing)
subtitle - Plot subtitle (not supported in plotly)
aspect.ratio - Aspect ratio control (handled by plotly layout)
legend.position - Legend positioning (plotly allows interactive repositioning)
y_sep - Separator for y columns (not applicable in UI context)
flip - Flip axes (not implemented in current UI)
split_by_sep - Separator for split columns (not applicable in UI context)
order_y - Y-axis ordering rules (handled by default logic)
lineheight - Text line height (not applicable in plotly)
max_charwidth - Maximum character width (not applicable in plotly)
fill_by_sep - Separator for fill columns (not applicable in UI context)
fill_name - Fill legend name (handled by plotly)
direction_pos_name - Positive direction name (not implemented)
direction_neg_name - Negative direction name (not implemented)
theme - ggplot2 theme (not applicable in plotly)
theme_args - Theme arguments (not applicable in plotly)
palette - Managed internally via the palette selection UI
keep_empty - Keep empty values (not implemented)
keep_na - Keep NA values (not implemented)
combine - Only applies if split_by is used
nrow - Only applies if split_by is used
ncol - Only applies if split_by is used
byrow - Only applies if split_by is used
seed - Random seed (not applicable)
axes - Only applies if split_by is used
axis_titles - Only applies if split_by is used
guides - Only applies if split_by is used
design - Only applies if split_by is used
legend_direction - Managed position of legend however this can be handled via plotly
The following plotthis::SplitBarPlot() parameters can be accessed via UI inputs and/or the defaults argument:
x - X-axis variable (UI: "X values", defaults key: x.data, default: 2nd numeric variable)
y - Y-axis grouping variable (UI: "Y values", defaults key: y.data, default: 2nd categorical variable)
fill_by - Fill color variable (UI: "Fill by", default: 2nd variable)
alpha_by - Variable for alpha transparency (UI: "Alpha by", default: "")
alpha_reverse - Reverse alpha order (UI: "Alpha reverse", default: FALSE)
alpha_name - Alpha legend name (UI: "Alpha name", default: "")
bar_height - Height of bars (UI: "Bar height", default: 0.9)
facet_by - Faceting variable (UI: "Facet by", default: "")
facet_scales - Facet scale behavior (UI: "Facet scale", default: "free_y")
facet_ncol - Number of facet columns (UI: "Facet number of columns", default: NULL)
facet_nrow - Number of facet rows (UI: "Facet number of rows", default: NULL)
facet_byrow - Facet ordering direction (UI: "Facet by row", default: TRUE)
split_by - Split variable (UI: "Split by", default: "")
x_min - Minimum X-axis value (UI: "X-axis min", default: calculated from data)
x_max - Maximum X-axis value (UI: "X-axis max", default: calculated from data)
palcolor - Custom color values (UI: palette picker, derived from palette)
The following parameters implementing new functionality or controlling plotly-specific features are also available:
label.on.y.axis - Show category labels on the Y axis instead of on the plot (UI: "Labels on Y axis", default: FALSE).
When enabled, the text position slider is hidden and labels appear as Y-axis tick labels.
text.position - Position of category labels along the X axis (UI: "Position of category labels", default: 0).
Only visible when label.on.y.axis is FALSE.
title.font.size - Plot title font size (UI: "Title Size", default: 26)
title.font.family - Font family for title text (UI: "Title Font", default: "Arial")
title.font.color - Color for plot title (UI: "Title Color", default: "#000000")
axis.title.font.size - Axis title font size (UI: "Axis Title Size", default: 18)
axis.title.font.color - Axis title font color (UI: "Axis Title Color", default: "#000000")
axis.title.font.family - Axis title font family (UI: "Axis Title Font", default: "Arial")
axis.showline - Show axis border lines (UI: "Show axis lines", default: TRUE)
axis.mirror - Mirror axis lines on opposite side (UI: "Mirror axis lines", default: TRUE)
show.grid.x - Show X-axis major gridlines (UI: "Show X major gridlines", default: TRUE)
show.grid.y - Show Y-axis major gridlines (UI: "Show Y major gridlines", default: TRUE)
axis.linecolor - Color of axis lines (UI: "Axis line color", default: "black")
axis.linewidth - Width of axis lines (UI: "Axis line width", default: 0.5)
axis.tickfont.size - Size of tick labels (UI: "Tick label size", default: 12)
axis.tickfont.color - Color of tick labels (UI: "Tick label color", default: "black")
axis.tickfont.family - Font family for tick labels (UI: "Tick label font", default: "Arial")
axis.tickangle.x - Rotation angle for X-axis tick labels (UI: "X-axis tick label angle", default: 0)
axis.tickangle.y - Rotation angle for Y-axis tick labels (UI: "Y-axis tick label angle", default: 0)
axis.ticks - Position of tick marks (UI: "Tick position", default: "outside")
axis.tickcolor - Color of tick marks (UI: "Tick mark color", default: "black")
axis.ticklen - Length of tick marks (UI: "Tick mark length", default: 5)
axis.tickwidth - Width of tick marks (UI: "Tick mark width", default: 1)
hline.intercepts - Y-coordinates for horizontal reference lines (UI: "Y-intercepts", default: "")
hline.colors - Colors for horizontal lines (UI: "Colors", default: "#000000")
hline.widths - Widths for horizontal lines (UI: "Widths", default: "1")
hline.linetypes - Line types for horizontal lines (UI: "Line types", default: "dashed")
hline.opacities - Opacities for horizontal lines (UI: "Opacities (0-1)", default: "1")
vline.intercepts - X-coordinates for vertical reference lines (UI: "X-intercepts", default: "")
vline.colors - Colors for vertical lines (UI: "Colors", default: "#000000")
vline.widths - Widths for vertical lines (UI: "Widths", default: "1")
vline.linetypes - Line types for vertical lines (UI: "Line types", default: "dashed")
vline.opacities - Opacities for vertical lines (UI: "Opacities (0-1)", default: "1")
abline.slopes - Slopes for diagonal reference lines (UI: "Slopes", default: "")
abline.intercepts - Y-intercepts for diagonal lines (UI: "Y-intercepts", default: "")
abline.colors - Colors for diagonal lines (UI: "Colors", default: "#000000")
abline.widths - Widths for diagonal lines (UI: "Widths", default: "1")
abline.linetypes - Line types for diagonal lines (UI: "Line types", default: "dashed")
abline.opacities - Opacities for diagonal lines (UI: "Opacities (0-1)", default: "1")
Jacob Martin
plotthis::SplitBarPlot(), organize_inputs(),
plotthis_SplitBarPlotOutputUI(), plotthis_SplitBarPlotServer(), plotthis_SplitBarPlotApp()
library(VizModules) mtcars$cyl <- as.factor(mtcars$cyl) plotthis_SplitBarPlotInputsUI("splitBarPlot", mtcars)library(VizModules) mtcars$cyl <- as.factor(mtcars$cyl) plotthis_SplitBarPlotInputsUI("splitBarPlot", mtcars)
This should be placed in the UI where the plot should be shown.
plotthis_SplitBarPlotOutputUI(id)plotthis_SplitBarPlotOutputUI(id)
id |
The ID for the Shiny module. |
A Shiny plotlyOutput for the SplitBarPlot
Jacob Martin
Server logic for SplitBarPlot module
plotthis_SplitBarPlotServer( id, data, hide.inputs = NULL, hide.tabs = NULL, defaults = NULL )plotthis_SplitBarPlotServer( id, data, hide.inputs = NULL, hide.tabs = NULL, defaults = NULL )
id |
The ID for the Shiny module. |
data |
A |
hide.inputs |
A character vector of input IDs to hide. These will still be initialized and their values passed to the plot function, but the user will not be able to see/adjust them in the UI. |
hide.tabs |
A character vector of tab names to hide. Inputs in these tabs will still be initialized and their values passed to the plot function, but the user will not be able to see/adjust them in the UI. |
defaults |
A named list of default values for the inputs. When the reset button is clicked, inputs are reset to these values rather than hardcoded fallbacks. Typically the same list passed to the corresponding UI function. |
The moduleServer function for the SplitBarPlot module.
Jacob Martin, Jared Andrews
plotthis::SplitBarPlot(), organize_inputs(),
plotthis_SplitBarPlotInputsUI(), plotthis_SplitBarPlotOutputUI(),
plotthis_SplitBarPlotApp()
This function generates a Shiny application with modular plotthis::ViolinPlot() components.
The app features a Data Import section for uploading data,
a Data Table for filtering the active dataset, and a Plot area
for configuring and displaying an interactive violin plot.
plotthis_ViolinPlotApp(data_list = NULL)plotthis_ViolinPlotApp(data_list = NULL)
data_list |
An optional named list of data frames. If |
When data_list is not provided (or NULL), the app launches with
example_demographics as an example dataset. Uploaded data files are added
to the available datasets and can be selected for plotting. If an uploaded
file shares a name with an existing dataset, the existing one is overwritten
with a warning.
This is a convenience wrapper around createModuleApp().
A Shiny app object.
Jacob Martin, Jared Andrews
library(VizModules) # Launch with default example data: app <- plotthis_ViolinPlotApp() if (interactive()) runApp(app) # Launch with custom data: app2 <- plotthis_ViolinPlotApp(list("demographics" = example_demographics)) if (interactive()) runApp(app2)library(VizModules) # Launch with default example data: app <- plotthis_ViolinPlotApp() if (interactive()) runApp(app) # Launch with custom data: app2 <- plotthis_ViolinPlotApp(list("demographics" = example_demographics)) if (interactive()) runApp(app2)
This should be placed in the UI where the inputs should be shown, with an id
that matches the id used in the plotthis_ViolinPlotServer() and plotthis_ViolinPlotOutputUI() functions.
plotthis_ViolinPlotInputsUI( id, data, defaults = NULL, title = NULL, columns = 2 )plotthis_ViolinPlotInputsUI( id, data, defaults = NULL, title = NULL, columns = 2 )
id |
The ID for the Shiny module. |
data |
The data frame used for plot generation. |
defaults |
A named list of default values for the inputs. |
title |
An optional title for the UI grid. |
columns |
Number of columns for the UI grid. |
The user inputs for this module are separated from the outputs to allow for more flexible UI design.
The inputs will automatically be organized into a grid layout via the organize_inputs() function,
with columns controlling the number of columns in the grid.
Defaults can be set for each input by providing a named list of values to the defaults argument.
Nearly all parameters for plotthis::ViolinPlot() can be set via these inputs, so see the help
for that function for an exhaustive list.
A Shiny tagList containing the UI elements
The following plotthis::ViolinPlot() parameters are not available via UI inputs:
xlab - X-axis label (plotly allows interactive editing)
ylab - Y-axis label (plotly allows interactive editing)
title - Plot title (plotly allows interactive editing)
subtitle - Plot subtitle (not supported in plotly)
aspect.ratio - Aspect ratio control (handled by plotly layout)
legend.position - Legend positioning (plotly allows interactive repositioning)
x_sep - Separator for x columns (not applicable in UI context)
in_form - Data input format (not applicable - always long form)
split_by - Split variable (returns a patchwork object, not supported in plotly), use facet_by instead
split_by_sep - Only applies if split_by is used
symnum_args - Significance symbol arguments (not implemented)
flip - Flip axes (not implemented in current UI)
keep_empty - Keep empty values (not implemented)
keep_na - Keep NA values (not implemented)
group_by_sep - Separator for group columns (not applicable in UI context)
group_name - Group legend name (handled by plotly)
paired_by - Pairing variable for paired tests (not implemented)
x_text_angle - X-axis text angle (handled by plotly axis settings)
step_increase - Step increase for significance brackets (not implemented)
fill_mode - Fill mode for grouped data (handled automatically)
fill_reverse - Reverse fill order (not implemented)
theme - ggplot2 theme (not applicable in plotly)
theme_args - Theme arguments (not applicable in plotly)
palette - Managed internally via the palette selection UI
alpha - Alpha transparency (not implemented in UI)
stack - Stack violins (not implemented)
add_beeswarm - Add beeswarm points (not implemented in UI)
beeswarm_method - Beeswarm arrangement method (not implemented)
beeswarm_cex - Beeswarm point size factor (not implemented)
beeswarm_priority - Beeswarm priority order (not implemented)
beeswarm_dodge - Beeswarm dodge width (not implemented)
add_trend - Add trend line (not implemented in UI)
trend_color - Trend line color (not implemented)
trend_linewidth - Trend line width (not implemented)
trend_ptsize - Trend point size (not implemented)
add_stat - Add statistical annotation (not implemented)
stat_name - Statistical test name (not implemented)
stat_color - Statistical annotation color (not implemented)
stat_size - Statistical annotation size (not implemented)
stat_stroke - Statistical annotation stroke (not implemented)
stat_shape - Statistical annotation shape (not implemented)
add_bg - Add background shading (not implemented)
bg_palette - Background palette (not implemented)
bg_palcolor - Background color (not implemented)
bg_alpha - Background transparency (not implemented)
add_line - Add horizontal line (not implemented in UI - use Lines tab)
line_color - Line color (not implemented)
line_width - Line width (not implemented)
line_type - Line type (not implemented)
comparisons - Group comparisons for significance tests (not implemented)
ref_group - Reference group for comparisons (not implemented)
pairwise_method - Pairwise test method (not implemented)
multiplegroup_comparisons - Multiple group comparison flag (not implemented)
multiple_method - Multiple group test method (not implemented)
sig_label - Significance label format (not implemented)
sig_labelsize - Significance label size (not implemented)
hide_ns - Hide non-significant comparisons (not implemented)
seed - Random seed (not applicable)
combine - Only applies if split_by is used
nrow - Only applies if split_by is used
ncol - Only applies if split_by is used
byrow - Only applies if split_by is used
axes - Only applies if split_by is used
axis_titles - Only applies if split_by is used
guides - Only applies if split_by is used
legend_direction - Managed position of legend however this can be handled via plotly
The following plotthis::ViolinPlot() parameters can be accessed via UI inputs and/or the defaults argument:
x - X-axis variable (UI: "X Data", default: 2nd categorical variable)
y - Y-axis variable (UI: "Y Data", default: 2nd numeric variable)
group_by - Grouping variable (UI: "Group By", default: "")
sort_x - Sort X-axis by statistic (UI: "Sort X By", default: "none")
y_max - Maximum Y-axis value (UI: "Y Max", default: calculated)
y_min - Minimum Y-axis value (UI: "Y Min", default: calculated)
add_point - Add jitter points (UI: "Add Jitter Points", default: FALSE)
pt_size - Point size (UI: "Point Size", default: 1)
pt_alpha - Point transparency (UI: "Point Alpha", default: 1)
jitter_width - Jitter width (UI: "Jitter Width", default: 0.5)
jitter_height - Jitter height (UI: "Jitter Height", default: 0)
pt_color - Point outline color (UI: "Point Outline Colour", default: "#000000")
add_box - Add box plot overlay (UI: "Add Box", default: FALSE)
box_color - Box outline color (UI: "Box Colour", default: "#000000")
box_width - Box width (UI: "Box Width", default: 0.1)
box_ptsize - Box point size (UI: "Box Point Size", default: 2.5)
highlight - Highlight condition (UI: "Highlight", default: "")
highlight_color - Highlight color (UI: "Highlight Colour", default: "#000000")
highlight_size - Highlight size (UI: "Highlight Size", default: 1)
highlight_alpha - Highlight transparency (UI: "Highlight Alpha", default: 1)
facet_by - Faceting variable (UI: "Facet By", default: "")
facet_scales - Facet scale behavior (UI: "Facet Scale", default: "fixed")
facet_ncol - Number of facet columns (UI: "Columns", default: NULL)
facet_nrow - Number of facet rows (UI: "Rows", default: NULL)
facet_byrow - Facet ordering direction (UI: "Facet By Row", default: TRUE)
palcolor - Custom color values (UI: palette picker, derived from palette)
The following parameters implementing new functionality or controlling plotly-specific features are also available:
title.font.size - Plot title font size (UI: "Title Size", default: 26)
title.font.family - Font family for title text (UI: "Title Font", default: "Arial")
title.font.color - Color for plot title (UI: "Title Color", default: "#000000")
axis.title.font.size - Axis title font size (UI: "Axis Title Size", default: 18)
axis.title.font.color - Axis title font color (UI: "Axis Title Color", default: "#000000")
axis.title.font.family - Axis title font family (UI: "Axis Title Font", default: "Arial")
axis.showline - Show axis border lines (UI: "Show axis lines", default: TRUE)
axis.mirror - Mirror axis lines on opposite side (UI: "Mirror axis lines", default: TRUE)
show.grid.x - Show X-axis major gridlines (UI: "Show X major gridlines", default: TRUE)
show.grid.y - Show Y-axis major gridlines (UI: "Show Y major gridlines", default: TRUE)
axis.linecolor - Color of axis lines (UI: "Axis line color", default: "black")
axis.linewidth - Width of axis lines (UI: "Axis line width", default: 0.5)
axis.tickfont.size - Size of tick labels (UI: "Tick label size", default: 12)
axis.tickfont.color - Color of tick labels (UI: "Tick label color", default: "black")
axis.tickfont.family - Font family for tick labels (UI: "Tick label font", default: "Arial")
axis.tickangle.x - Rotation angle for X-axis tick labels (UI: "X-axis tick label angle", default: 0)
axis.tickangle.y - Rotation angle for Y-axis tick labels (UI: "Y-axis tick label angle", default: 0)
axis.ticks - Position of tick marks (UI: "Tick position", default: "outside")
axis.tickcolor - Color of tick marks (UI: "Tick mark color", default: "black")
axis.ticklen - Length of tick marks (UI: "Tick mark length", default: 5)
axis.tickwidth - Width of tick marks (UI: "Tick mark width", default: 1)
hline.intercepts - Y-coordinates for horizontal reference lines (UI: "Y-intercepts", default: "")
hline.colors - Colors for horizontal lines (UI: "Colors", default: "#000000")
hline.widths - Widths for horizontal lines (UI: "Widths", default: "1")
hline.linetypes - Line types for horizontal lines (UI: "Line types", default: "dashed")
hline.opacities - Opacities for horizontal lines (UI: "Opacities (0-1)", default: "1")
vline.intercepts - X-coordinates for vertical reference lines (UI: "X-intercepts", default: "")
vline.colors - Colors for vertical lines (UI: "Colors", default: "#000000")
vline.widths - Widths for vertical lines (UI: "Widths", default: "1")
vline.linetypes - Line types for vertical lines (UI: "Line types", default: "dashed")
vline.opacities - Opacities for vertical lines (UI: "Opacities (0-1)", default: "1")
abline.slopes - Slopes for diagonal reference lines (UI: "Slopes", default: "")
abline.intercepts - Y-intercepts for diagonal lines (UI: "Y-intercepts", default: "")
abline.colors - Colors for diagonal lines (UI: "Colors", default: "#000000")
abline.widths - Widths for diagonal lines (UI: "Widths", default: "1")
abline.linetypes - Line types for diagonal lines (UI: "Line types", default: "dashed")
abline.opacities - Opacities for diagonal lines (UI: "Opacities (0-1)", default: "1")
Jacob Martin, Jared Andrews
plotthis::ViolinPlot(), organize_inputs(),
plotthis_ViolinPlotOutputUI(), plotthis_ViolinPlotServer(),
plotthis_ViolinPlotApp()
library(VizModules) data(mtcars) plotthis_ViolinPlotInputsUI("ViolinPlot", mtcars)library(VizModules) data(mtcars) plotthis_ViolinPlotInputsUI("ViolinPlot", mtcars)
This should be placed in the UI where the plot should be shown.
plotthis_ViolinPlotOutputUI(id)plotthis_ViolinPlotOutputUI(id)
id |
The ID for the Shiny module. |
A Shiny plotlyOutput for the ViolinPlot
Jacob Martin
Server logic for ViolinPlot module
plotthis_ViolinPlotServer( id, data, hide.inputs = NULL, hide.tabs = NULL, defaults = NULL )plotthis_ViolinPlotServer( id, data, hide.inputs = NULL, hide.tabs = NULL, defaults = NULL )
id |
The ID for the Shiny module. |
data |
A |
hide.inputs |
A character vector of input IDs to hide. These will still be initialized and their values passed to the plot function, but the user will not be able to see/adjust them in the UI. |
hide.tabs |
A character vector of tab names to hide. Inputs in these tabs will still be initialized and their values passed to the plot function, but the user will not be able to see/adjust them in the UI. |
defaults |
A named list of default values for the inputs. When the reset button is clicked, inputs are reset to these values rather than hardcoded fallbacks. Typically the same list passed to the corresponding UI function. |
The moduleServer function for the ViolinPlot module.
Jacob Martin, Jared Andrews
Create a plotly radar chart
radarPlot( df, theta, r, group = NULL, colors = NULL, palette = NULL, fill = "toself", line.width = 2, line.dash = "solid", marker.size = 5, marker.symbol = "circle", opacity = 0.6, radial.visible = TRUE, radial.range = NULL, radial.showline = TRUE, radial.linecolor = "#444444", radial.gridcolor = "#EEEEEE", angular.direction = "clockwise", angular.rotation = 90, angular.gridcolor = "#EEEEEE", show.legend = TRUE, legend.orientation = "h", legend.x = 0.5, legend.y = -0.1, legend.font.family = "Arial", legend.font.size = 12, legend.font.color = "#000000", title.text = "", title.font.family = "Arial", title.font.size = 18, title.font.color = "#000000", title.x = 0.5, bgcolor = "#FFFFFF", polar.bgcolor = "#FFFFFF" )radarPlot( df, theta, r, group = NULL, colors = NULL, palette = NULL, fill = "toself", line.width = 2, line.dash = "solid", marker.size = 5, marker.symbol = "circle", opacity = 0.6, radial.visible = TRUE, radial.range = NULL, radial.showline = TRUE, radial.linecolor = "#444444", radial.gridcolor = "#EEEEEE", angular.direction = "clockwise", angular.rotation = 90, angular.gridcolor = "#EEEEEE", show.legend = TRUE, legend.orientation = "h", legend.x = 0.5, legend.y = -0.1, legend.font.family = "Arial", legend.font.size = 12, legend.font.color = "#000000", title.text = "", title.font.family = "Arial", title.font.size = 18, title.font.color = "#000000", title.x = 0.5, bgcolor = "#FFFFFF", polar.bgcolor = "#FFFFFF" )
df |
A data frame containing the data to plot. For a single trace, provide columns for categories (theta) and values (r). For multiple traces, include a grouping column. The function automatically closes the radar polygon by adding the first point to the end. |
theta |
Character, name of the column to use for the angular categories (axes). |
r |
Character, name of the column to use for the radial values. |
group |
Optional character, name of the column to use for grouping multiple traces. If NULL, a single trace is plotted. Default: NULL. |
colors |
Optional character vector of hex colors for the traces. If named, values are matched to the group values; otherwise colours are recycled. |
palette |
Optional character vector of fallback colors used when
|
fill |
Logical or character, whether to fill the area under each trace. Use "toself" to fill to the first point, or FALSE for no fill. Default: "toself". |
line.width |
Numeric, width of the trace lines in pixels. Default: 2. |
line.dash |
Character, line dash style. Options: "solid", "dot", "dash", "longdash", "dashdot", "longdashdot". Default: "solid". |
marker.size |
Numeric, size of the markers on the trace. Default: 5. |
marker.symbol |
Character, marker symbol. Options: "circle", "square", "diamond", "cross", "x", "triangle-up", etc. Default: "circle". |
opacity |
Numeric, opacity of the traces (0-1). Default: 0.6. |
radial.visible |
Logical, whether to show the radial axis. Default: TRUE. |
radial.range |
Optional numeric vector of length 2 specifying the range of the radial axis (e.g., c(0, 100)). If NULL, automatically determined. Default: NULL. |
radial.showline |
Logical, whether to show the radial axis line. Default: TRUE. |
radial.linecolor |
Character, hex color for the radial axis line. Default: "#444444". |
radial.gridcolor |
Character, hex color for the radial grid lines. Default: "#EEEEEE". |
angular.direction |
Character, direction of angular axis. Options: "clockwise" or "counterclockwise". Default: "clockwise". |
angular.rotation |
Numeric, rotation angle for the angular axis in degrees. Default: 90. |
angular.gridcolor |
Character, hex color for the angular grid lines. Default: "#EEEEEE". |
show.legend |
Logical, whether to display the legend. Default: TRUE. |
legend.orientation |
Character, legend orientation. Options: "h" (horizontal) or "v" (vertical). Default: "h". |
legend.x |
Numeric, horizontal legend position offset (0-1). Default: 0.5. |
legend.y |
Numeric, vertical legend position offset (-1 to 1). Default: -0.1. |
legend.font.family |
Character, font family for the legend text. Default: "Arial". |
legend.font.size |
Numeric, font size for the legend text. Default: 12. |
legend.font.color |
Character, hex color for the legend text. Default: "#000000". |
title.text |
Character, main plot title text. Default: "". |
title.font.family |
Character, font family for the title text. Default: "Arial". |
title.font.size |
Numeric, font size for the title text. Default: 18. |
title.font.color |
Character, hex color for the title text. Default: "#000000". |
title.x |
Numeric, horizontal position for the plot title (0-1). Default: 0.5. |
bgcolor |
Character, hex color for the plot background. Default: "#FFFFFF". |
polar.bgcolor |
Character, hex color for the polar area background. Default: "#FFFFFF". |
A plotly object.
Jacob Martin
# Single trace radar chart # Note: Polygon is automatically closed by the function skills <- data.frame( category = c("Speed", "Strength", "Defense", "Stamina"), value = c(8, 6, 7, 9) ) radarPlot( df = skills, theta = "category", r = "value", title.text = "Player Stats" ) # Multiple trace radar chart # Note: Polygon is automatically closed for each trace team_stats <- data.frame( category = rep(c("Speed", "Strength", "Defense", "Stamina"), 2), value = c(8, 6, 7, 9, 5, 9, 8, 6), player = rep(c("Player A", "Player B"), each = 4) ) radarPlot( df = team_stats, theta = "category", r = "value", group = "player", title.text = "Team Comparison" )# Single trace radar chart # Note: Polygon is automatically closed by the function skills <- data.frame( category = c("Speed", "Strength", "Defense", "Stamina"), value = c(8, 6, 7, 9) ) radarPlot( df = skills, theta = "category", r = "value", title.text = "Player Stats" ) # Multiple trace radar chart # Note: Polygon is automatically closed for each trace team_stats <- data.frame( category = rep(c("Speed", "Strength", "Defense", "Stamina"), 2), value = c(8, 6, 7, 9, 5, 9, 8, 6), player = rep(c("Player A", "Player B"), each = 4) ) radarPlot( df = team_stats, theta = "category", r = "value", group = "player", title.text = "Team Comparison" )
This function generates a Shiny application with modular radarPlot components. The app features a Data Import section for uploading data, a Data Table for filtering the active dataset, and a Plot area for configuring and displaying an interactive radar plot.
radarPlotApp(data_list = NULL)radarPlotApp(data_list = NULL)
data_list |
An optional named list of data frames. If |
When data_list is not provided (or NULL), the app launches with
example_skills as an example dataset. Uploaded data files are added
to the available datasets and can be selected for plotting. If an uploaded
file shares a name with an existing dataset, the existing one is overwritten
with a warning.
This is a convenience wrapper around createModuleApp().
A Shiny app object.
Jacob Martin, Jared Andrews
radarPlot(), radarPlotInputsUI(),
radarPlotOutputUI(), radarPlotServer()
library(VizModules) # Launch with default example data: app <- radarPlotApp() if (interactive()) runApp(app) # Launch with custom data: skills <- data.frame( entity = c( rep("Player A", 6), rep("Player B", 6), rep("Player C", 6), rep("Player D", 6) ), category = rep(c("Pace", "Shooting", "Passing", "Dribbling", "Defending", "Physical"), 4), value = c( 99, 89, 80, 92, 36, 78, 89, 97, 65, 72, 45, 95, 76, 86, 94, 86, 64, 78, 62, 60, 71, 63, 94, 91 ) ) app2 <- radarPlotApp(list("skills" = skills)) if (interactive()) runApp(app2)library(VizModules) # Launch with default example data: app <- radarPlotApp() if (interactive()) runApp(app) # Launch with custom data: skills <- data.frame( entity = c( rep("Player A", 6), rep("Player B", 6), rep("Player C", 6), rep("Player D", 6) ), category = rep(c("Pace", "Shooting", "Passing", "Dribbling", "Defending", "Physical"), 4), value = c( 99, 89, 80, 92, 36, 78, 89, 97, 65, 72, 45, 95, 76, 86, 94, 86, 64, 78, 62, 60, 71, 63, 94, 91 ) ) app2 <- radarPlotApp(list("skills" = skills)) if (interactive()) runApp(app2)
This should be placed in the UI where the inputs should be shown, with an id
that matches the id used in the radarPlotServer() and radarPlotOutputUI() functions.
radarPlotInputsUI(id, data, defaults = NULL, title = NULL, columns = 2)radarPlotInputsUI(id, data, defaults = NULL, title = NULL, columns = 2)
id |
The ID for the Shiny module. |
data |
The data frame used for plot generation. |
defaults |
A named list of default values for the inputs. |
title |
An optional title for the UI grid. |
columns |
Number of columns for the UI grid. |
The user inputs for this module are separated from the outputs to allow for more flexible UI design.
The inputs will automatically be organized into a grid layout via the organize_inputs() function,
with columns controlling the number of columns in the grid.
Defaults can be set for each input by providing a named list of values to the defaults argument.
Provide data with columns for categories (theta) and values (r). For multiple traces,
include a grouping column.
Nearly all parameters for radarPlot() can be set via these inputs, so see the help
for that function for an exhaustive list.
A Shiny tagList containing the UI elements
The following radarPlot() parameters can be accessed via UI inputs
and/or the defaults argument:
theta - Category column for angular axes
(UI: "Category column (theta)", default: 1st categorical column)
r - Values column for radial distance (UI: "Values column (r)", default: 1st numeric column)
group - Optional grouping column for multiple traces (UI: "Group column", default: NULL)
fill - Fill area under trace (UI: "Fill area", default: "toself")
line.width - Line width (UI: "Line width", default: 2)
line.dash - Line dash style (UI: "Line style", default: "solid")
marker.size - Marker size (UI: "Marker size", default: 5)
marker.symbol - Marker symbol (UI: "Marker symbol", default: "circle")
opacity - Trace opacity (UI: "Opacity", default: 0.6)
colors - Trace colors (UI: color picker, derived from palette)
radial.visible - Show radial axis (UI: "Show radial axis", default: TRUE)
radial.range - Radial axis range (UI: "Radial min" and "Radial max", default: auto)
radial.showline - Show radial axis line (UI: "Show radial line", default: TRUE)
radial.linecolor - Radial axis line color (UI: "Radial line color", default: "#444444")
radial.gridcolor - Radial grid color (UI: "Radial grid color", default: "#EEEEEE")
angular.direction - Angular axis direction (UI: "Angular direction", default: "clockwise")
angular.rotation - Angular axis rotation (UI: "Angular rotation", default: 90)
angular.gridcolor - Angular grid color (UI: "Angular grid color", default: "#EEEEEE")
title.x - Title horizontal position (UI: "Title horizontal position", default: 0.5)
title.font.size - Plot title font size (UI: "Title Size", default: 26)
title.font.family - Font family for title text (UI: "Title Font", default: "Arial")
title.font.color - Color for plot title (UI: "Title Color", default: "#000000")
show.legend - Show legend (UI: "Show legend", default: TRUE)
legend.orientation - Legend orientation (UI: "Legend orientation", default: "h")
legend.font.family - Legend font (UI: "Legend font", default: "Arial")
legend.font.size - Legend font size (UI: "Legend font size", default: 12)
legend.font.color - Legend font color (UI: "Legend font color", default: "#000000")
bgcolor - Plot background color (UI: "Plot background color", default: "#FFFFFF")
polar.bgcolor - Polar area background color (UI: "Polar area background", default: "#FFFFFF")
Jacob Martin
radarPlot(), organize_inputs(),
radarPlotOutputUI(), radarPlotServer(), radarPlotApp()
library(VizModules) skills <- data.frame( category = c("Speed", "Strength", "Defense", "Stamina", "Speed"), value = c(8, 6, 7, 9, 8) ) radarPlotInputsUI("radarPlot", skills)library(VizModules) skills <- data.frame( category = c("Speed", "Strength", "Defense", "Stamina", "Speed"), value = c(8, 6, 7, 9, 8) ) radarPlotInputsUI("radarPlot", skills)
This should be placed in the UI where the plot should be shown.
radarPlotOutputUI(id)radarPlotOutputUI(id)
id |
The ID for the Shiny module. |
A Shiny plotlyOutput for the radarPlot
Jared Andrews
Server logic for radarPlot module
radarPlotServer( id, data, hide.inputs = NULL, hide.tabs = NULL, defaults = NULL )radarPlotServer( id, data, hide.inputs = NULL, hide.tabs = NULL, defaults = NULL )
id |
The ID for the Shiny module. |
data |
A |
hide.inputs |
A character vector of input IDs to hide. These will still be initialized and their values passed to the plot function, but the user will not be able to see/adjust them in the UI. |
hide.tabs |
A character vector of tab names to hide. Inputs in these tabs will still be initialized and their values passed to the plot function, but the user will not be able to see/adjust them in the UI. |
defaults |
A named list of default values for the inputs. When the reset button is clicked, inputs are reset to these values rather than hardcoded fallbacks. Typically the same list passed to the corresponding UI function. |
The moduleServer function for the radarPlot module.
Jacob Martin
radarPlot(), radarPlotInputsUI(),
radarPlotOutputUI(), radarPlotApp()
Maps groups to colors using selected colors or a default palette. Handles named color vectors by matching to group names, fills in missing colors with fallback values, and ensures the output vector is named and matches group length.
resolve_palette(groups, selected_colors = NULL, default_palette = NULL)resolve_palette(groups, selected_colors = NULL, default_palette = NULL)
groups |
A character vector of group names to assign colors to. |
selected_colors |
A named or unnamed character vector of colors to use.
If named, colors are matched to groups by name. If NULL or empty, uses
|
default_palette |
A character vector of fallback colors to use when
|
A named character vector of colors with names corresponding to groups, or NULL if groups is empty.
Jared Andrews
groups <- c("A", "B", "C") colors <- c(A = "#FF0000", B = "#00FF00", C = "#0000FF") resolve_palette(groups, colors) # Returns: c(A = "#FF0000", B = "#00FF00", C = "#0000FF") # Using default palette resolve_palette(groups, NULL, c("#1B9E77", "#D95F02", "#7570B3")) # Returns: c(A = "#1B9E77", B = "#D95F02", C = "#7570B3")groups <- c("A", "B", "C") colors <- c(A = "#FF0000", B = "#00FF00", C = "#0000FF") resolve_palette(groups, colors) # Returns: c(A = "#FF0000", B = "#00FF00", C = "#0000FF") # Using default palette resolve_palette(groups, NULL, c("#1B9E77", "#D95F02", "#7570B3")) # Returns: c(A = "#1B9E77", B = "#D95F02", C = "#7570B3")
Parses the expression text, validates that it only contains allowed
operations (comparisons, logical operators, column references, and
literals), then evaluates it in a restricted environment containing
only the data frame columns. Returns a logical vector suitable for
row subsetting, or NULL if the input is empty or invalid.
safe_eval_filter(expr_text, data)safe_eval_filter(expr_text, data)
expr_text |
Character string containing the filter expression
(e.g., |
data |
A |
Use this function any time a module evaluates a user-typed expression
directly (e.g., a row-filter text input). Never call eval(str2expression())
on raw user input — doing so allows arbitrary code execution on the server.
A logical vector the same length as nrow(data), or NULL if the
input is empty, unparseable, or contains disallowed operations.
Jared Andrews
safe_eval_filter("Sepal.Length > 5", iris) safe_eval_filter("Sepal.Length > 5 & Species == 'setosa'", iris) safe_eval_filter("", iris) # NULL safe_eval_filter("system('echo pwned')", iris) # NULL + warningsafe_eval_filter("Sepal.Length > 5", iris) safe_eval_filter("Sepal.Length > 5 & Species == 'setosa'", iris) safe_eval_filter("", iris) # NULL safe_eval_filter("system('echo pwned')", iris) # NULL + warning
Validates that the provided function name is in the allowed list before
converting it to a function reference. Returns NULL for empty strings
or unrecognized names.
safe_resolve_adj_fxn(fn_name)safe_resolve_adj_fxn(fn_name)
fn_name |
Character string — name of the adjustment function.
Currently allowed values: |
Use this instead of eval(str2expression()) when resolving function names
from user input (e.g., a dropdown that selects a transformation like
"log2" or "sqrt").
The corresponding function, or NULL if fn_name is empty or
not in the allowed list.
Jared Andrews
safe_resolve_adj_fxn("log2") # returns log2 safe_resolve_adj_fxn("") # NULL safe_resolve_adj_fxn("system") # warning + NULLsafe_resolve_adj_fxn("log2") # returns log2 safe_resolve_adj_fxn("") # NULL safe_resolve_adj_fxn("system") # warning + NULL
A helper function that encapsulates the common pattern of handling auto-update functionality in module servers. When auto-update is disabled, it adds a dependency on the update button. Returns a wrapper function that either isolates reactive expressions or passes them through unchanged.
setup_auto_update_logic(input)setup_auto_update_logic(input)
input |
The Shiny input object from the module server,
should have both |
This function consolidates the following common pattern:
auto_update <- input$auto.update
if (!auto_update) {
input$update
}
isolate_fn <- if (auto_update) identity else isolate
Usage in a reactive context:
output$plot <- renderPlotly({
isolate_fn <- setup_auto_update_logic(input)
# Now use isolate_fn to wrap input values
x_val <- isolate_fn(input$x.value)
})
A function that wraps reactive expressions. Returns identity if auto-update
is enabled (expressions will be reactive), or isolate if auto-update is disabled
(expressions will not trigger reactivity).
Jared Andrews
if (interactive()) { library(shiny) library(plotly) ui <- fluidPage( selectInput("x_var", "X variable", choices = names(mtcars), selected = "wt"), selectInput("y_var", "Y variable", choices = names(mtcars), selected = "mpg"), checkboxInput("auto.update", "Auto-update", value = TRUE), actionButton("update", "Update"), plotlyOutput("myPlot") ) server <- function(input, output, session) { output$myPlot <- renderPlotly({ isolate_fn <- setup_auto_update_logic(input) x_val <- isolate_fn(input$x_var) y_val <- isolate_fn(input$y_var) plot_ly(mtcars, x = ~ .data[[x_val]], y = ~ .data[[y_val]], type = "scatter", mode = "markers") }) } shinyApp(ui, server) }if (interactive()) { library(shiny) library(plotly) ui <- fluidPage( selectInput("x_var", "X variable", choices = names(mtcars), selected = "wt"), selectInput("y_var", "Y variable", choices = names(mtcars), selected = "mpg"), checkboxInput("auto.update", "Auto-update", value = TRUE), actionButton("update", "Update"), plotlyOutput("myPlot") ) server <- function(input, output, session) { output$myPlot <- renderPlotly({ isolate_fn <- setup_auto_update_logic(input) x_val <- isolate_fn(input$x_var) y_val <- isolate_fn(input$y_var) plot_ly(mtcars, x = ~ .data[[x_val]], y = ~ .data[[y_val]], type = "scatter", mode = "markers") }) } shinyApp(ui, server) }
Create a plotly ternary plot
ternaryPlot( df, a, b, c, group = NULL, colors = NULL, palette = NULL, sum = 100, mode = "markers", marker.size = 8, marker.symbol = "circle", marker.line.width = 0, marker.line.color = "#000000", line.width = 2, line.dash = "solid", opacity = 1, a.title = "a", b.title = "b", c.title = "c", a.titlefont.size = 16, b.titlefont.size = 16, c.titlefont.size = 16, a.titlefont.family = "Arial", b.titlefont.family = "Arial", c.titlefont.family = "Arial", a.titlefont.color = "#000000", b.titlefont.color = "#000000", c.titlefont.color = "#000000", a.tickfont.size = 12, b.tickfont.size = 12, c.tickfont.size = 12, a.tickcolor = "rgba(0,0,0,0)", b.tickcolor = "rgba(0,0,0,0)", c.tickcolor = "rgba(0,0,0,0)", a.ticklen = 5, b.ticklen = 5, c.ticklen = 5, a.gridcolor = "#EEEEEE", b.gridcolor = "#EEEEEE", c.gridcolor = "#EEEEEE", show.legend = TRUE, legend.orientation = "h", legend.x = 0.5, legend.y = -0.1, legend.font.family = "Arial", legend.font.size = 12, legend.font.color = "#000000", title.text = "", title.font.family = "Arial", title.font.size = 18, title.font.color = "#000000", title.x = 0.5, bgcolor = "#FFFFFF" )ternaryPlot( df, a, b, c, group = NULL, colors = NULL, palette = NULL, sum = 100, mode = "markers", marker.size = 8, marker.symbol = "circle", marker.line.width = 0, marker.line.color = "#000000", line.width = 2, line.dash = "solid", opacity = 1, a.title = "a", b.title = "b", c.title = "c", a.titlefont.size = 16, b.titlefont.size = 16, c.titlefont.size = 16, a.titlefont.family = "Arial", b.titlefont.family = "Arial", c.titlefont.family = "Arial", a.titlefont.color = "#000000", b.titlefont.color = "#000000", c.titlefont.color = "#000000", a.tickfont.size = 12, b.tickfont.size = 12, c.tickfont.size = 12, a.tickcolor = "rgba(0,0,0,0)", b.tickcolor = "rgba(0,0,0,0)", c.tickcolor = "rgba(0,0,0,0)", a.ticklen = 5, b.ticklen = 5, c.ticklen = 5, a.gridcolor = "#EEEEEE", b.gridcolor = "#EEEEEE", c.gridcolor = "#EEEEEE", show.legend = TRUE, legend.orientation = "h", legend.x = 0.5, legend.y = -0.1, legend.font.family = "Arial", legend.font.size = 12, legend.font.color = "#000000", title.text = "", title.font.family = "Arial", title.font.size = 18, title.font.color = "#000000", title.x = 0.5, bgcolor = "#FFFFFF" )
df |
A data frame containing the data to plot. Must contain numeric columns for the three ternary axes (a, b, c). For multiple traces, include a grouping column. |
a |
Character, name of the column to use for the a-axis (top vertex). |
b |
Character, name of the column to use for the b-axis (bottom-left vertex). |
c |
Character, name of the column to use for the c-axis (bottom-right vertex). |
group |
Optional character, name of the column to use for grouping multiple traces. If NULL, a single trace is plotted. Default: NULL. |
colors |
Optional character vector of hex colors for the traces. If named, values are matched to the group values; otherwise colours are recycled. |
palette |
Optional character vector of fallback colors used when
|
sum |
Numeric, the constant sum for the ternary axes (e.g., 100 for percentages, 1 for proportions). All data points should sum to this value. Default: 100. |
mode |
Character, the trace mode. Options: "markers", "lines", "lines+markers". Default: "markers". |
marker.size |
Numeric, size of the markers on the trace. Default: 8. |
marker.symbol |
Character, marker symbol. Options: "circle", "square", "diamond", "cross", "x", "triangle-up", etc. Default: "circle". |
marker.line.width |
Numeric, width of the marker border line. Default: 0. |
marker.line.color |
Character, hex color for the marker border. Default: "#000000". |
line.width |
Numeric, width of the trace lines in pixels (only used if mode includes "lines"). Default: 2. |
line.dash |
Character, line dash style. Options: "solid", "dot", "dash", "longdash", "dashdot", "longdashdot". Default: "solid". |
opacity |
Numeric, opacity of the traces (0-1). Default: 1. |
a.title |
Character, title for the a-axis. Default: "a". |
b.title |
Character, title for the b-axis. Default: "b". |
c.title |
Character, title for the c-axis. Default: "c". |
a.titlefont.size |
Numeric, font size for the a-axis title. Default: 16. |
b.titlefont.size |
Numeric, font size for the b-axis title. Default: 16. |
c.titlefont.size |
Numeric, font size for the c-axis title. Default: 16. |
a.titlefont.family |
Character, font family for the a-axis title. Default: "Arial". |
b.titlefont.family |
Character, font family for the b-axis title. Default: "Arial". |
c.titlefont.family |
Character, font family for the c-axis title. Default: "Arial". |
a.titlefont.color |
Character, hex color for the a-axis title. Default: "#000000". |
b.titlefont.color |
Character, hex color for the b-axis title. Default: "#000000". |
c.titlefont.color |
Character, hex color for the c-axis title. Default: "#000000". |
a.tickfont.size |
Numeric, font size for the a-axis tick labels. Default: 12. |
b.tickfont.size |
Numeric, font size for the b-axis tick labels. Default: 12. |
c.tickfont.size |
Numeric, font size for the c-axis tick labels. Default: 12. |
a.tickcolor |
Character, hex color for the a-axis ticks. Default: "rgba(0,0,0,0)". |
b.tickcolor |
Character, hex color for the b-axis ticks. Default: "rgba(0,0,0,0)". |
c.tickcolor |
Character, hex color for the c-axis ticks. Default: "rgba(0,0,0,0)". |
a.ticklen |
Numeric, length of the a-axis ticks. Default: 5. |
b.ticklen |
Numeric, length of the b-axis ticks. Default: 5. |
c.ticklen |
Numeric, length of the c-axis ticks. Default: 5. |
a.gridcolor |
Character, hex color for the a-axis gridlines. Default: "#EEEEEE". |
b.gridcolor |
Character, hex color for the b-axis gridlines. Default: "#EEEEEE". |
c.gridcolor |
Character, hex color for the c-axis gridlines. Default: "#EEEEEE". |
show.legend |
Logical, whether to display the legend. Default: TRUE. |
legend.orientation |
Character, legend orientation. Options: "h" (horizontal) or "v" (vertical). Default: "h". |
legend.x |
Numeric, horizontal legend position offset (0-1). Default: 0.5. |
legend.y |
Numeric, vertical legend position offset (-1 to 1). Default: -0.1. |
legend.font.family |
Character, font family for the legend text. Default: "Arial". |
legend.font.size |
Numeric, font size for the legend text. Default: 12. |
legend.font.color |
Character, hex color for the legend text. Default: "#000000". |
title.text |
Character, main plot title text. Default: "". |
title.font.family |
Character, font family for the title text. Default: "Arial". |
title.font.size |
Numeric, font size for the title text. Default: 18. |
title.font.color |
Character, hex color for the title text. Default: "#000000". |
title.x |
Numeric, horizontal position for the plot title (0-1). Default: 0.5. |
bgcolor |
Character, hex color for the plot background. Default: "#FFFFFF". |
A plotly object.
Jacob Martin
# Single trace ternary plot journalist <- c(75, 70, 75, 5, 10, 10, 20, 10, 15, 10, 20) developer <- c(25, 10, 20, 60, 80, 90, 70, 20, 5, 10, 10) designer <- c(0, 20, 5, 35, 10, 0, 10, 70, 80, 80, 70) label <- c( "point 1", "point 2", "point 3", "point 4", "point 5", "point 6", "point 7", "point 8", "point 9", "point 10", "point 11" ) df <- data.frame(journalist, developer, designer, label) ternaryPlot( df = df, a = "journalist", b = "developer", c = "designer", a.title = "Journalist", b.title = "Developer", c.title = "Designer", title.text = "Simple Ternary Plot with Markers" ) # Multiple trace ternary plot with grouping team_data <- data.frame( journalist = c(75, 70, 75, 5, 10, 10), developer = c(25, 10, 20, 60, 80, 90), designer = c(0, 20, 5, 35, 10, 0), team = rep(c("Team A", "Team B"), each = 3) ) ternaryPlot( df = team_data, a = "journalist", b = "developer", c = "designer", group = "team", a.title = "Journalist", b.title = "Developer", c.title = "Designer", title.text = "Team Comparison" )# Single trace ternary plot journalist <- c(75, 70, 75, 5, 10, 10, 20, 10, 15, 10, 20) developer <- c(25, 10, 20, 60, 80, 90, 70, 20, 5, 10, 10) designer <- c(0, 20, 5, 35, 10, 0, 10, 70, 80, 80, 70) label <- c( "point 1", "point 2", "point 3", "point 4", "point 5", "point 6", "point 7", "point 8", "point 9", "point 10", "point 11" ) df <- data.frame(journalist, developer, designer, label) ternaryPlot( df = df, a = "journalist", b = "developer", c = "designer", a.title = "Journalist", b.title = "Developer", c.title = "Designer", title.text = "Simple Ternary Plot with Markers" ) # Multiple trace ternary plot with grouping team_data <- data.frame( journalist = c(75, 70, 75, 5, 10, 10), developer = c(25, 10, 20, 60, 80, 90), designer = c(0, 20, 5, 35, 10, 0), team = rep(c("Team A", "Team B"), each = 3) ) ternaryPlot( df = team_data, a = "journalist", b = "developer", c = "designer", group = "team", a.title = "Journalist", b.title = "Developer", c.title = "Designer", title.text = "Team Comparison" )
This function generates a Shiny application with modular ternaryPlot components. The app features a Data Import section for uploading data, a Data Table for filtering the active dataset, and a Plot area for configuring and displaying an interactive ternary plot.
ternaryPlotApp(data_list = NULL)ternaryPlotApp(data_list = NULL)
data_list |
An optional named list of data frames. If |
When data_list is not provided (or NULL), the app launches with
example_roles as an example dataset. Uploaded data files are added
to the available datasets and can be selected for plotting. If an uploaded
file shares a name with an existing dataset, the existing one is overwritten
with a warning.
This is a convenience wrapper around createModuleApp().
A Shiny app object.
Jacob Martin, Jared Andrews
ternaryPlot(), ternaryPlotInputsUI(),
ternaryPlotOutputUI(), ternaryPlotServer()
library(VizModules) # Launch with default example data: app <- ternaryPlotApp() if (interactive()) runApp(app) # Launch with custom data: df <- data.frame( journalist = c(75, 70, 75, 5, 10), developer = c(25, 10, 20, 60, 80), designer = c(0, 20, 5, 35, 10) ) app2 <- ternaryPlotApp(list("roles" = df)) if (interactive()) runApp(app2)library(VizModules) # Launch with default example data: app <- ternaryPlotApp() if (interactive()) runApp(app) # Launch with custom data: df <- data.frame( journalist = c(75, 70, 75, 5, 10), developer = c(25, 10, 20, 60, 80), designer = c(0, 20, 5, 35, 10) ) app2 <- ternaryPlotApp(list("roles" = df)) if (interactive()) runApp(app2)
This should be placed in the UI where the inputs should be shown, with an id
that matches the id used in the ternaryPlotServer() and ternaryPlotOutputUI() functions.
ternaryPlotInputsUI(id, data, defaults = NULL, title = NULL, columns = 2)ternaryPlotInputsUI(id, data, defaults = NULL, title = NULL, columns = 2)
id |
The ID for the Shiny module. |
data |
The data frame used for plot generation. |
defaults |
A named list of default values for the inputs. |
title |
An optional title for the UI grid. |
columns |
Number of columns for the UI grid. |
The user inputs for this module are separated from the outputs to allow for more flexible UI design.
The inputs will automatically be organized into a grid layout via the organize_inputs() function,
with columns controlling the number of columns in the grid.
Defaults can be set for each input by providing a named list of values to the defaults argument.
Provide data with numeric columns for the three ternary axes (a, b, c). For multiple traces,
include a grouping column.
Nearly all parameters for ternaryPlot() can be set via these inputs, so see the help
for that function for an exhaustive list.
A Shiny tagList containing the UI elements
The following ternaryPlot() parameters are not accessible via UI inputs:
a.titlefont.family, b.titlefont.family, c.titlefont.family -
Axis title font families (use defaults to set)
a.titlefont.color, b.titlefont.color, c.titlefont.color -
Axis title font colors (use defaults to set)
a.tickfont.size, b.tickfont.size, c.tickfont.size -
Axis tick label font sizes (use defaults to set)
a.tickcolor, b.tickcolor, c.tickcolor -
Axis tick colors (use defaults to set)
a.ticklen, b.ticklen, c.ticklen -
Axis tick length (use defaults to set)
legend.x, legend.y - Legend position offsets (use defaults to set)
title.x - Title horizontal position (use defaults to set)
palette - Color palette name; use colors via the color picker UI instead
The following ternaryPlot() parameters can be accessed via UI inputs
and/or the defaults argument:
a - Column for a-axis (top vertex)
(UI: "A-axis column", default: 1st numeric column)
b - Column for b-axis (bottom-left vertex)
(UI: "B-axis column", default: 2nd numeric column)
c - Column for c-axis (bottom-right vertex)
(UI: "C-axis column", default: 3rd numeric column)
group - Optional grouping column for multiple traces (UI: "Group column", default: NULL)
sum - Constant sum for ternary axes (UI: "Sum", default: 100)
mode - Trace mode (UI: "Mode", default: "markers")
marker.size - Marker size (UI: "Marker size", default: 8)
marker.symbol - Marker symbol (UI: "Marker symbol", default: "circle")
marker.line.width - Marker border width (UI: "Marker border width", default: 0)
line.width - Line width (UI: "Line width", default: 2)
line.dash - Line dash style (UI: "Line style", default: "solid")
opacity - Trace opacity (UI: "Opacity", default: 1)
colors - Trace colors (UI: color picker, derived from palette)
a.title - A-axis title (UI: "A-axis title", default: column name)
b.title - B-axis title (UI: "B-axis title", default: column name)
c.title - C-axis title (UI: "C-axis title", default: column name)
a.titlefont.size - A-axis title font size (UI: "A-axis title size", default: 16)
b.titlefont.size - B-axis title font size (UI: "B-axis title size", default: 16)
c.titlefont.size - C-axis title font size (UI: "C-axis title size", default: 16)
a.gridcolor - A-axis grid color (UI: "A-axis grid color", default: "#EEEEEE")
b.gridcolor - B-axis grid color (UI: "B-axis grid color", default: "#EEEEEE")
c.gridcolor - C-axis grid color (UI: "C-axis grid color", default: "#EEEEEE")
title.font.size - Plot title font size (UI: "Title Size", default: 26)
title.font.family - Font family for title text (UI: "Title Font", default: "Arial")
title.font.color - Color for plot title (UI: "Title Color", default: "#000000")
show.legend - Show legend (UI: "Show legend", default: TRUE)
legend.orientation - Legend orientation (UI: "Legend orientation", default: "h")
legend.font.family - Legend font (UI: "Legend font", default: "Arial")
legend.font.size - Legend font size (UI: "Legend font size", default: 12)
legend.font.color - Legend font color (UI: "Legend font color", default: "#000000")
bgcolor - Plot background color (UI: "Background color", default: "#FFFFFF")
Jacob Martin
ternaryPlot(), organize_inputs(),
ternaryPlotOutputUI(), ternaryPlotServer(), ternaryPlotApp()
library(VizModules) df <- data.frame( a_val = c(75, 70, 75, 5, 10), b_val = c(25, 10, 20, 60, 80), c_val = c(0, 20, 5, 35, 10) ) ternaryPlotInputsUI("ternaryPlot", df)library(VizModules) df <- data.frame( a_val = c(75, 70, 75, 5, 10), b_val = c(25, 10, 20, 60, 80), c_val = c(0, 20, 5, 35, 10) ) ternaryPlotInputsUI("ternaryPlot", df)
This should be placed in the UI where the plot should be shown.
ternaryPlotOutputUI(id)ternaryPlotOutputUI(id)
id |
The ID for the Shiny module. |
A Shiny plotlyOutput for the ternaryPlot
Jacob Martin
Server logic for ternaryPlot module
ternaryPlotServer( id, data, hide.inputs = NULL, hide.tabs = NULL, defaults = NULL )ternaryPlotServer( id, data, hide.inputs = NULL, hide.tabs = NULL, defaults = NULL )
id |
The ID for the Shiny module. |
data |
A |
hide.inputs |
A character vector of input IDs to hide. These will still be initialized and their values passed to the plot function, but the user will not be able to see/adjust them in the UI. |
hide.tabs |
A character vector of tab names to hide. Inputs in these tabs will still be initialized and their values passed to the plot function, but the user will not be able to see/adjust them in the UI. |
defaults |
A named list of default values for the inputs. When the reset button is clicked, inputs are reset to these values rather than hardcoded fallbacks. Typically the same list passed to the corresponding UI function. |
The moduleServer function for the ternaryPlot module.
Jacob Martin
ternaryPlot(), ternaryPlotInputsUI(),
ternaryPlotOutputUI(), ternaryPlotApp()
Change the color values assigned to groups in an existing multiColorPicker input from the server side. You can supply explicit colors, apply a palette by name, or reset the widget back to its initial state.
updateMultiColorPicker( session, inputId, colors = NULL, palette = NULL, reset = FALSE )updateMultiColorPicker( session, inputId, colors = NULL, palette = NULL, reset = FALSE )
session |
The Shiny session object, typically |
inputId |
Character. The input id of the multiColorPicker to update. |
colors |
Optional named character vector of hex colors keyed by group
name. Only groups present in the vector will be updated; others remain
unchanged. Ignored when |
palette |
Optional character string giving the name of a palette
(as supplied in the widget's |
reset |
Logical. If |
Invisibly returns NULL. Called for its side effect.
Jared Andrews
if (interactive()) { library(shiny) groups <- c("setosa", "virginica", "versicolor") ui <- fluidPage( multiColorPicker( "species_cols", "Species colors", groups = groups, selected_palette = "dittoColors" ), actionButton("randomize", "Randomize colors"), actionButton("apply_pal", "Apply ggplot2 palette"), actionButton("reset_cols", "Reset to initial"), verbatimTextOutput("chosen") ) server <- function(input, output, session) { output$chosen <- renderPrint(input$species_cols) observeEvent(input$randomize, { new_colors <- setNames( sprintf("#%06X", sample(0xFFFFFF, length(groups))), groups ) updateMultiColorPicker(session, "species_cols", colors = new_colors) }) observeEvent(input$apply_pal, { updateMultiColorPicker(session, "species_cols", palette = "ggplot2") }) observeEvent(input$reset_cols, { updateMultiColorPicker(session, "species_cols", reset = TRUE) }) } shinyApp(ui, server) }if (interactive()) { library(shiny) groups <- c("setosa", "virginica", "versicolor") ui <- fluidPage( multiColorPicker( "species_cols", "Species colors", groups = groups, selected_palette = "dittoColors" ), actionButton("randomize", "Randomize colors"), actionButton("apply_pal", "Apply ggplot2 palette"), actionButton("reset_cols", "Reset to initial"), verbatimTextOutput("chosen") ) server <- function(input, output, session) { output$chosen <- renderPrint(input$species_cols) observeEvent(input$randomize, { new_colors <- setNames( sprintf("#%06X", sample(0xFFFFFF, length(groups))), groups ) updateMultiColorPicker(session, "species_cols", colors = new_colors) }) observeEvent(input$apply_pal, { updateMultiColorPicker(session, "species_cols", palette = "ggplot2") }) observeEvent(input$reset_cols, { updateMultiColorPicker(session, "species_cols", reset = TRUE) }) } shinyApp(ui, server) }
Parses the expression text and walks the AST to ensure it only contains
allowed operations (comparisons, logical operators, column references, and
literals). Returns the original string if valid, or NULL if the input
is empty, unparseable, or contains disallowed operations. This is useful
when the expression string must be passed through to a downstream function
(e.g., plotthis::BoxPlot(highlight = ...)) rather than evaluated directly.
validate_expression(expr_text, col_names)validate_expression(expr_text, col_names)
expr_text |
Character string containing the expression to validate
(e.g., |
col_names |
Character vector of allowed column/symbol names
(typically |
Use this when a module passes a user-typed expression string to an external plotting function that will evaluate it internally. The string is validated but not executed by this function.
The original expr_text string if safe, or NULL.
Jared Andrews
validate_expression("Sepal.Length > 5", names(iris)) validate_expression("system('echo pwned')", names(iris)) # NULL + warning validate_expression("", names(iris)) # NULLvalidate_expression("Sepal.Length > 5", names(iris)) validate_expression("system('echo pwned')", names(iris)) # NULL + warning validate_expression("", names(iris)) # NULL