ggstatsplot (version 0.0.5)

ggscatterstats: Scatterplot with marginal distributions

Description

Scatterplots from ggplot2 combined with marginal histograms/boxplots/density plots with statistical details added as a subtitle.

Usage

ggscatterstats(data, x, y, xlab = NULL, ylab = NULL, line.size = 1.5,
  line.color = "blue", marginal = TRUE, marginal.type = "histogram",
  marginal.size = 5, margins = c("both", "x", "y"),
  width.jitter = NULL, height.jitter = NULL, xfill = "#009E73",
  yfill = "#D55E00", xalpha = 1, yalpha = 1, xsize = 0.7,
  ysize = 0.7, centrality.para = NULL, type = "pearson",
  results.subtitle = NULL, title = NULL, caption = NULL,
  nboot = 100, beta = 0.1, k = 3, axes.range.restrict = FALSE,
  ggtheme = ggplot2::theme_bw(), messages = TRUE)

Arguments

data

Dataframe from which variables specified are preferentially to be taken.

x

A vector containing the explanatory variable.

y

The response - a vector of length the number of rows of x.

xlab

Label for x axis variable.

ylab

Label for y axis variable.

line.size

Size for the regression line.

line.color

color for the regression line.

marginal

Decides whether ggExtra::ggMarginal() plots will be displayed; the default is TRUE.

marginal.type

Type of marginal distribution to be plotted on the axes ("histogram", "boxplot", "density", "violin", "densigram").

marginal.size

Integer describing the relative size of the marginal plots compared to the main plot. A size of 5 means that the main plot is 5x wider and 5x taller than the marginal plots.

margins

Character describing along which margins to show the plots. Any of the following arguments are accepted: "both", "x", "y".

width.jitter

Degree of jitter in x direction. Defaults to 40% of the resolution of the data.

height.jitter

Degree of jitter in y direction. Defaults to 40% of the resolution of the data.

xfill, yfill

Character describing color fill for x and y axes marginal distributions (default: "#009E73" (for x) and "#D55E00" (for y)).

xalpha, yalpha

Numeric deciding transparency levels for the marginal distributions. Any numbers from 0 (transparent) to 1 (opaque). The default is 1 for both axes.

xsize, ysize

Size for the marginal distribution boundaries (Default: 0.7).

centrality.para

Decides which measure of central tendency ("mean" or "median") is to be displayed as vertical (for x) and horizontal (for y) lines.

type

Type of association between paired samples required (""parametric": Pearson's product moment correlation coefficient" or ""nonparametric": Spearman's rho" or ""robust": Robust regression using an M estimator"). Corresponding abbreviations are also accepted: "p" (for parametric/pearson's), "np" (nonparametric/spearman), "r" (robust), resp.

results.subtitle

Decides whether the results of statistical tests are to be displayed as subtitle.

title

The text for the plot title.

caption

The text for the plot caption.

nboot

Number of bootstrap samples for computing effect size (Default: 100).

beta

bending constant (Default: 0.1). For more, see ?WRS2::pbcor.

k

Number of decimal places expected for results.

axes.range.restrict

Logical decides whether to restrict the axes values ranges to min and max values of the x and y variables (Default: FALSE).

ggtheme

A function, ggplot2 theme name. Default value is ggplot2::theme_bw(). Allowed values are the official ggplot2 themes, including theme_grey(), theme_minimal(), theme_classic(), theme_void(), etc.

messages

Decides whether messages references, notes, and warnings are to be displayed (Default: TRUE).

References

https://indrajeetpatil.github.io/ggstatsplot/articles/ggscatterstats.html

See Also

grouped_ggscatterstats ggcorrmat grouped_ggcorrmat

Examples

Run this code
# NOT RUN {
# to get reproducible results from bootstrapping
set.seed(123)

# simple function call with the defaults
ggstatsplot::ggscatterstats(
  data = datasets::mtcars,
  x = wt,
  y = mpg,
  type = "np"
)
# }

Run the code above in your browser using DataLab