Ploting with qplot
Overview
Teaching: 10 min
Exercises: 0 minQuestions
How to quick plot in R using ggplot2 package
Objectives
Learn professional plotting tool in R using qplot
Learn multiple way to use qplot
What is qplot
- qplot stands for quick plot in ggplot2.
- It is similar to basic plot in R but with ggplot 2’s standard
In this episode, we gonna learn how to quickly visualize data using qplot
Basic qplot: Scatter plot
- Plots are made of aes (size, shape, color) and geom (points, lines)
- Look for data in frame (or from parent directory)
qplot(Sepal.Length, Sepal.Width, data=iris) - Add aesthetic (shape, color)
qplot(Sepal.Length, Petal.Length, data=iris, color=factor(Species), shape=factor(Species)) #aesthetic
- Add geom (points, lines)
qplot(Sepal.Length, Petal.Length, data=iris, geom=c("point","smooth")) #geometry
- Linear Fitting
qplot(Sepal.Length, Petal.Length, data=iris, color=Species, geom=c("point","smooth"),method="lm")
Basic qplot: Histogram
qplot(Sepal.Length,fill=Species, data=iris)
qplot(Sepal.Length,data=iris,geom="density")
qplot(Sepal.Length,data=iris,geom="density",
color=Species)

Basic qplot: Facets
qplot(Sepal.Length,Petal.Length,facets=.~Species, data=iris)

Key Points
ggplot2
qplot