Learn R Programming

daltoolbox (version 1.2.747)

plot_scatter: Scatter graph

Description

Scatter plot from a long data.frame with columns named x, value, and variable.

Usage

plot_scatter(data, label_x = "", label_y = "", colors = NULL)

Value

return a ggplot2::ggplot graphic

Arguments

data

long data.frame with columns x, value, variable

label_x

x‑axis label

label_y

y‑axis label

colors

optional color(s); for numeric variable, supply a gradient as c(low, high)

Details

Colors are mapped to variable. If variable is numeric, a gradient color scale is used when colors is provided.

Examples

Run this code
grf <- plot_scatter(iris |> dplyr::select(x = Sepal.Length,
value = Sepal.Width, variable = Species),
label_x = "Sepal.Length", label_y = "Sepal.Width",
colors=c("red", "green", "blue"))
plot(grf)

Run the code above in your browser using DataLab