Input UI components for the BarPlot module
Source:R/plotthis_BarPlot_module_ui.R
plotthis_BarPlotInputsUI.RdThis 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.
Arguments
- 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. An entry may also be a
shiny::reactive()orshiny::reactiveVal(); it is resolved withshiny::isolate()to seed the control, and the module then keeps it live (seesetup_reactive_defaults()).- title
An optional title for the UI grid.
- columns
Number of columns for the UI grid.
Details
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.
Plot parameters not implemented or with altered functionality
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- Split variable (returns a patchwork object, not supported in plotly), usefacet_byinsteadsplit_by_sep- Only applies ifsplit_byis usedfill_name- Name of the fill legend (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 UIx_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- Only applies ifsplit_byis usednrow- Only applies ifsplit_byis usedncol- Only applies ifsplit_byis usedbyrow- Only applies ifsplit_byis usedseed- Random seed (not applicable)axes- Only applies ifsplit_byis usedaxis_titles- Only applies ifsplit_byis usedguides- Only applies ifsplit_byis useddesign- Only applies ifsplit_byis used
Plot parameters and defaults
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)fill_by- Variable used to fill the bars (UI: "Fill by", default: "")flip- Flip/swap the x and y axes (UI: "Rotate (swap X/Y)", default: FALSE)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)palreverse- Reverse the color palette (UI: "Reverse palette", default: FALSE)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)lower_quantile- Lower quantile for the continuous fill color scale (UI: "Lower Quantile", default: 0); only affects a numericfill_byupper_quantile- Upper quantile for the continuous fill color scale (UI: "Upper Quantile", default: 1); only affects a numericfill_bylower_cutoff- Explicit lower cutoff for the continuous fill color scale (UI: "Lower Cutoff", default: NA); overrideslower_quantilewhen setupper_cutoff- Explicit upper cutoff for the continuous fill color scale (UI: "Upper Cutoff", default: NA); overridesupper_quantilewhen set
Parameters controlling additional functionality
The following parameters implementing new functionality or controlling plotly-specific features are also available:
x.order- Order of the X values (UI: "X Order", drag and drop, default: the column's factor level order, else sorted). As a default, a character vector of levels ofx.data; levels it leaves out follow in their default order. Not shown for an X with more than 20 valuestitle.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)axis.scientific- Write numeric tick labels in scientific notation (UI: "Scientific Notation Ticks", default: FALSE; when off they never switch to it). Seeapply_tick_notation()axis.padding.x- Space between the data and the plot area's edges along X, as a fraction of the data's extent at each end (UI: "X Axis Padding", default: NA = the plot's own). Seeapply_axis_padding()legend.show- Show the legend and any colorbar (UI: "Show Legend", default: TRUE)legend.font.family- Font family of the legend title and labels (UI: "Legend Font", default: "Arial")legend.font.color- Font color of the legend title and labels (UI: "Legend Font Color", default: "#000000")legend.title.size- Legend title font size (UI: "Legend Title Size", default: 14)legend.text.size- Legend entry label font size (UI: "Legend Text Size", default: 12)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")palette.colours- Named character vector mapping group levels to colors, e.g.c(A = "#FF0000", B = "blue")(UI: "Plot colors"). Seeds the picker; unnamed groups fall back to the default palette and user edits take precedence.palette.name- Gradient palette used whenfill.byis numeric (UI: "Color Palette", default: "viridis")
Examples
if (FALSE) { # interactive()
library(VizModules)
data(mtcars)
plotthis_BarPlotInputsUI("BarPlot", mtcars)
}