ggplot2 intro
Covers the basic knowledge about
1. Understanding the Ggplot Syntax:
# Setup
options(scipen=999) # turn off scientific notation like 1e+06
library(ggplot2)
data("midwest", package = "ggplot2") # load the data
# Init Ggplot
ggplot(midwest, aes(x=area, y=poptotal)) # area and poptotal are columns in 'midwest'2. How to Make a Simple Scatterplot:
ggplot(midwest, aes(x=area, y=poptotal)) +
geom_point() 

3. Adjusting the X and Y axis limits:
Method 1: By deleting the points outside the range
Method 2: Zooming In
4. How to Change the Title and Axis Labels:
5. How to Change the Color and Size of Points:
#How to Change the Color and Size To Static?

#How to Change the Color To Reflect Categories in Another Column?



6. How to Change the X Axis Texts and Ticks Location:
#How to Change the X and Y Axis Text and its Location?
#How to Write Customized Texts for Axis Labels, by Formatting the Original Values?
#How to Customize the Entire Theme in One Shot using Pre-Built Themes?

Last updated