Skip to contents

Automatically selects and generates the most appropriate plot type based on variable data types using the esquisse package. Supports 40+ plot type combinations including histograms, scatter plots, box plots, violin plots, bar charts, line plots, and more. Perfect for quick data visualization with intelligent defaults.

Usage

esquisseauto(
  data,
  xvar,
  yvar,
  colorvar,
  fillvar,
  sizevar,
  groupvar,
  facetvar,
  autoGeom = TRUE,
  manualGeom = "auto",
  plotTheme = "minimal",
  plotTitle = "",
  plotSubtitle = "",
  plotCaption = "",
  xLabel = "",
  yLabel = "",
  legendTitle = "",
  legendPosition = "right",
  xAxisAngle = 0,
  yAxisAngle = 0,
  showCode = FALSE,
  addSmoother = FALSE,
  flipAxes = FALSE,
  showInstructions = TRUE
)

Arguments

data

The data as a data frame.

xvar

Variable for x-axis. Can be continuous, discrete, or time-based.

yvar

Variable for y-axis. Leave empty for univariate plots (histograms, bar charts). Can be continuous, discrete, or time-based.

colorvar

Variable to use for coloring points/bars/lines. Creates grouped visualizations.

fillvar

Variable to use for filling bars/areas. Different from color (outline).

sizevar

Variable to use for sizing points/lines. Typically continuous variables.

groupvar

Variable to use for grouping (useful for line plots to connect points).

facetvar

Variable to use for creating faceted (small multiple) plots.

autoGeom

Automatically select the most appropriate plot type based on variable types. Disable to manually choose from available geoms.

manualGeom

Manually select plot type. Only used when Auto-Select is disabled.

plotTheme

Visual theme for the plot.

plotTitle

Custom title for the plot. Leave empty for automatic title.

plotSubtitle

Subtitle text displayed below the title. Leave empty for no subtitle.

plotCaption

Caption text displayed at bottom-right of plot (e.g., data source, notes).

xLabel

Custom label for x-axis. Leave empty to use variable name.

yLabel

Custom label for y-axis. Leave empty to use variable name.

legendTitle

Custom title for the legend. Leave empty to use variable name.

legendPosition

Position of the legend or hide it completely.

xAxisAngle

Rotation angle for x-axis labels (0-90 degrees). Useful for long labels.

yAxisAngle

Rotation angle for y-axis labels (0-90 degrees).

showCode

Display the R code generated by esquisse for reproducing this plot.

addSmoother

Add a smoothed trend line to scatter plots.

flipAxes

Swap x and y axes (useful for horizontal bar charts).

showInstructions

Display helpful instructions about how to use this module.

Value

A results object containing:

results$instructionsa html
results$plotinfoa html
results$plotan image
results$generatedCodea preformatted

Examples

# Auto-select plot type based on variables
esquisseauto(
    data = mtcars,
    xvar = "cyl",
    yvar = "mpg"
)

# With color grouping
esquisseauto(
    data = iris,
    xvar = "Species",
    yvar = "Sepal.Length",
    colorvar = "Species"
)