Answers for "plot scatter"

0

Scatter graph

# the iris dataset is provided by R natively

# Create a color palette
library(paletteer)
colors <- paletteer_c(package = "ggthemes", palette = "Green-Blue-White", n = 3)

# Scatterplot with categoric color scale
plot(
  x = iris$Petal.Length, 
  y = iris$Petal.Width,
  bg = colors[ unclass(iris$Species) ],
  cex = 3,
  pch=21
)
Posted by: Guest on July-24-2021
0

scatter plot

# Convert cyl column from a numeric to a factor variable
mtcars$cyl <- as.factor(mtcars$cyl)
head(mtcars)
Posted by: Guest on November-21-2021

Browse Popular Code Answers by Language