Page 271 - Data Science class 11
P. 271
xlab = "Month Number",
ylab = "Degree Fahrenheit",
col= ‘’Orange’’)
# Saving the file.
dev.off()
Running this code snippet will show following:
And the box plot as shown below:
7.9.3 example of using ggplot2 in boxplot
Boxplot in R ((use of geom_point() with ggplot())
Now let us see how you can plot a boxplot using the ggplot2 plotting package. Make sure that you have already
installed the package ggplot2 in R. Take care that the Internet is available.
Example
Enter the following code snippet in the script panel:
library(ggplot2)
set.seed(1234)
# Give the chart file a name.
png(file = "rating.png")
dat <- data.frame(setting = factor(rep(c("A","B"),each = 300)),
rating = c(rnorm(300),rnorm(300,mean = 0.5)))
Coding for Data Science Visualisation using R-Studio 269

