ggstatsplot (version 0.0.3)

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 = NULL, 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", centrality.para = NULL, type = "pearson",
  results.subtitle = NULL, title = NULL, caption = NULL, maxit = 500,
  k = 3, axes.range.restrict = FALSE, 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").

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

color fill for x axis distibution (default: "#009E73").

yfill

color fill for y axis distribution (default: "#D55E00").

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.

maxit

Maximum number of iterations for robust linear regression or bootstrap samples to compute Spearman's rho confidence intervals (Default: 500).

k

Number of decimal places expected for results.

axes.range.restrict

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

messages

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

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
)

# more detailed function call
ggstatsplot::ggscatterstats(
data = datasets::iris,
x = Petal.Length,
y = Sepal.Length,
centrality.para = 'median',
type = 'robust',
marginal.type = 'density'
)

# }

Run the code above in your browser using DataCamp Workspace