scatter_plot: Scatter Plot and Scatter Plot Matrix

View source: R/scatter_plot.R

scatter_plotR Documentation

Scatter Plot and Scatter Plot Matrix


Draw a scatter plot or a scatter plot matrix of variables in a data frame. The plots thereby mimic the look of SPSS graphs.


scatter_plot(data, variables, version = r2spss_options$get("version"), ...)



a data frame containing the variables to be plotted.


a character vector specifying at least two variables to be plotted. In case of two variables, a simple scatter plot is produced with the first variable on the x-axis and the second variable on the y-axis. In case of more than two variables, a scatter plot matrix is produced.


a character string specifying whether the plot should mimic the look of recent SPSS versions ("modern") or older versions (<24; "legacy").


for a simple scatter plot, additional arguments are passed down to geom_point. For a scatter plot matrix, additional arguments to be passed down, in particular base graphics parameters (see par).


In case of a simple scatter plot, an object of class "ggplot", which produces the plot when printed.

In case of a scatter plot matrix, nothing is returned but a plot is produced.


Wile all other plots in r2spss are based on ggplot2 (including the simple scatter plot), the scatter plot matrix is built around base R graphics. This is because ggplot2 does not provide an implementation of a scatter plot matrix, and an implementation based on separate scatter plots on a matrix layout would be slow.


Andreas Alfons


# load data
# log-transform market values
Eredivisie$logMarketValue <- log(Eredivisie$MarketValue)

# plot log market values against age
scatter_plot(Eredivisie, c("Age", "logMarketValue"))

# scatterplot matrix of age, number of minutes played, and
# log market values
scatter_plot(Eredivisie, c("Age", "Minutes", "logMarketValue"))

r2spss documentation built on May 25, 2022, 5:05 p.m.