iris
dataset. Probably, this is the most used set in the world of R. That is why we will take it in this post to demonstrate all the possibilities. plot(iris$Sepal.Length, iris$Sepal.Width, col = iris$Species) legend("topright", legend = levels(iris$Species), col = 1:3, pch = 21)
jitter()
function will help. ## , geom_jitter iris$Sepal.Length = jitter(iris$Sepal.Length) iris$Sepal.Width = jitter(iris$Sepal.Width)
palette()
function allows you to globally change the color palette for base graphs R. alpha = 150 # palette(c(rgb(200, 79, 178, alpha = alpha, maxColorValue = 255), rgb(105, 147, 45, alpha = alpha, maxColorValue = 255), rgb(85, 130, 169, alpha = alpha, maxColorValue = 255)))
par()
: par(mar = c(3, 3, 2, 1), # mgp = c(2, 0.4, 0), # las = 1, # tck = -.01, # xaxs = "i", yaxs = "i") #
plot()
function itself. There were flowers, and these are berries. We create a plot with the function plot()
with a lot of arguments: plot(iris$Sepal.Length, iris$Sepal.Width, bg = iris$Species, # pch = 21, # : xlab = "Sepal Length", ylab = "Sepal Width", # axes = FALSE, # frame.plot = FALSE, # xlim = c(4, 8), ylim = c(2, 4.5), # panel.first = abline(h = seq(2, 4.5, 0.5), col = "grey80"))
at = pretty(iris$Sepal.Length) mtext(side = 1, text = at, at = at, col = "grey20", line = 1, cex = 0.9)
at = pretty(iris$Sepal.Width) mtext(side = 2, text = at, at = at, col = "grey20", line = 1, cex = 0.9)
legend()
function, we will display the names near the dots with the text()
function. text(5, 4.2, "setosa", col = rgb(200, 79, 178, maxColorValue = 255)) text(5.3, 2.1, "versicolor", col = rgb(105, 147, 45, maxColorValue = 255)) text(7, 3.7, "virginica", col = rgb(85, 130, 169, maxColorValue = 255))
title("The infamous IRIS data", adj = 1, cex.main = 0.8, font.main = 2, col.main = "black")
Source: https://habr.com/ru/post/347710/
All Articles