Draw Legend Outside of Plot Area in Base R Graphic (Example Code) | legend() Function
Автор: Statistics Globe
Загружено: 2019-10-22
Просмотров: 7221
How to create a legend outside the plot area in a Base R graph in the R programming language. More details: https://statisticsglobe.com/draw-lege...
R code:
set.seed(123) # Set seed
data <- data.frame(x = c(rnorm(100), rnorm(100, 2)), # Create example data
y = c(rnorm(100), rnorm(100, 2)),
group = c(rep(1, 100), rep(2, 100)))
par(mar = c(5, 4, 4, 8), # Specify par parameters
xpd = TRUE)
plot(data$x, data$y, # Create plot
pch = data$group,
col = data$group)
legend("topright", inset = c(- 0.4, 0), # Create legend outside of plot
legend = c("Group 1","Group 2"),
pch = 1:2,
col = 1:2)
Доступные форматы для скачивания:
Скачать видео mp4
-
Информация по загрузке: