SmartRS

SmartRS

14- Basic plotting in R Programming

14- Basic plotting in R Programming

Load trees data from datasets library

library(datasets)
tr<-trees 
head(tr)

Histogram

hist(tr$Volume, col = 'darkred',main="Your title", xlab="Volume")

image.png

Barplot

barplot(tr$Height, names.arg=c(1:31), col='darkgreen')

image.png

Boxplot

boxplot(tr$Height, col = 'darkblue', xlab='Height',ylab='Height (m)')

image.png

boxplot(tr, col='darkorange')

image.png

Scatter plot

plot(tr$Height, tr$Volume, col='#FDAE61', pch=19, xlab='Height', ylab=
      'Volume', main='Your title')

image.png

plot(tr$Volume,tr$Height, col = factor(tr$Girth[1:6]), pch=19,
     xlab='Volume', ylab='Height', main='Your title')

# Legend
legend("topleft",
       legend = levels(factor(tr$Girth[1:6])),
       pch = 19,
       col = factor(levels(factor(tr$Girth[1:6]))))

image.png

Line graph

plot(tr$Height,type = "o",col = "darkgreen", xlab = "Day", ylab = "Value", 
     main = "Your title", ylim = c(0, 85), pch=18, lty=6)
lines(tr$Volume, type = "o", col = "darkblue", pch=19, lty=2)

image.png

#r#tutorial#research#programming-languages#coding
 
Share this
Proudly part of