Академический Документы
Профессиональный Документы
Культура Документы
Data Visualization
Sr No Task Command
1 Histogram of gpa
> hist(grades$gpa)
[File: grades.csv]
2 Histogram of gpa
hist(grades$gpa, xlab="gpa", ylab="Frequency", main = "Histogram of
Do proper labelling and Heading gpa" )
8 Box Plot of gpa versus ethnicity > boxplot(gpa~ethnicity, data = grades, main = "GPA versus
Ethnicity", xlab="Ethnicity", ylab="GPA")
9 Box Plot of gpa versus ethnicity > boxplot(gpa~ethnicity, data = grades, main = "GPA versus
One colour ‘red’ Ethnicity", xlab="Ethnicity", ylab="GPA", col= "red")
21 Make plot horizontal > barplot(counts, main = "Bar Plot of Etnicity", xlab="Etninicity",
horiz = T, ylab = "Counts", col = "red")
22 Label 1, 2, 3, 4 and 5 as Native, Asian, > barplot(counts, main = "Bar Plot of Etnicity", xlab="Etninicity",
ylab = "Counts", col = "red", names.arg = c("Native", "Asian",
Black, White & Hispanic respectively "Black", "White", "Hispanic"))
23 Different colours for each bar > barplot(counts, main = "Bar Plot of Etnicity", xlab="Etninicity",
ylab = "Counts", col = c("red", "blue", "green", "yellow",
"brown"), names.arg = c("Native", "Asian", "Black", "White",
"Hispanic"))
24 Insert Counts within bars > bp<-barplot(counts, main = "Bar Plot of Etnicity",
xlab="Etninicity", ylab = "Counts", col = c("red", "blue", "green",
"yellow", "brown"), names.arg = c("Native", "Asian", "Black",
"White", "Hispanic"))
30 Vioplot of gpa
> library(vioplot)
Package vioplot is already available in base > vioplot(grades$gpa, col = "red")
packages > title ("Violin Plot of gpa", xlab = "", ylab = "gpa")
31 > library(vioplot)
Violin Plot of gpa versus sections > x1<-grades$gpa[grades$section==1]
> x2<-grades$gpa[grades$section==2]
> x3<-grades$gpa[grades$section==3]
> vioplot(x1,x2,x3, names = c("Section 1", "Section 2", "Section
3"), col="gold")
> plot(1,1, xlim = c(0,3.5), ylim = range(c(x1,x2,x3)), type = "n",
xlab = "", ylab = "", axes = FALSE)
> axis(side = 1, at=1:3, labels=c("1st", "2nd","3rd"))
> axis(side=2)
> vioplot(x1,at=1, col="blue", add = TRUE)
> vioplot(x2,at=2, col="RED", add = TRUE)
> vioplot(x3,at=3, col="green", add = TRUE)
> title("Violin Plot of gpa versus Sections", xlab= "Sections",
ylab = "gpa")
> legend("topleft", fill = c("blue", "red", "green"), legend =
c("First", "Second", "Third"), box.lty = 1, cex=0.7)
32