library(ggplot2)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
mpg
## # A tibble: 234 x 11
## manufacturer model displ year cyl trans drv cty hwy fl class
## <chr> <chr> <dbl> <int> <int> <chr> <chr> <int> <int> <chr> <chr>
## 1 audi a4 1.8 1999 4 auto… f 18 29 p comp…
## 2 audi a4 1.8 1999 4 manu… f 21 29 p comp…
## 3 audi a4 2 2008 4 manu… f 20 31 p comp…
## 4 audi a4 2 2008 4 auto… f 21 30 p comp…
## 5 audi a4 2.8 1999 6 auto… f 16 26 p comp…
## 6 audi a4 2.8 1999 6 manu… f 18 26 p comp…
## 7 audi a4 3.1 2008 6 auto… f 18 27 p comp…
## 8 audi a4 q… 1.8 1999 4 manu… 4 18 26 p comp…
## 9 audi a4 q… 1.8 1999 4 auto… 4 16 25 p comp…
## 10 audi a4 q… 2 2008 4 manu… 4 20 28 p comp…
## # … with 224 more rows
ggplot(mpg,aes(mpg$class))+
geom_bar(aes(fill = mpg$trans))+ scale_fill_discrete(name = "Transmission")+
ggtitle("Visual # 1: Stacked Bar Chart")+
theme(legend.position = "right")+
xlab("class")+
ylab("count")+
theme(plot.title = element_text(hjust = 0.5))

ggplot(mpg, aes(x=manufacturer, y=hwy)) +
geom_boxplot()+
coord_flip()+
ggtitle("Visual # 2: Boxplot ")+
ylab("Highway Fuel Efficiency (miles/gallon)")+
xlab("Vehicle Manufacturer")

library(ggplot2)
ggplot(diamonds) +
geom_density(aes(price,
fill = cut,
color = cut),
alpha = 0.3,
size = 0.6) +
labs(title="Visual # 3: Density plot")+
ylab("Density")+
xlab("Dimond Price (USD)")+
theme(legend.position = "top")

ggplot(iris,
aes(Sepal.Length, Petal.Length)) +
geom_point() +
geom_smooth(method = lm) +
theme_minimal() +
theme(panel.grid.major = element_line(size = 1),
panel.grid.minor = element_line(size = 0.7)) +
labs(title = "Visual # 4: Relationship between Petal and Sepal Length")+
xlab("Iris Sepal Length")+
ylab("Iris Petal Length")

ggplot(iris,
aes(Sepal.Length,
Petal.Length,
color = Species)) +
geom_point() +
geom_smooth(method = lm, se = FALSE) +
theme(text = element_text(family = "serif"),
axis.ticks = element_line(color = "black",
size = 0.7),
legend.position = "bottom",
legend.title = element_text(face = "plain"),
plot.title = element_text(size = 14,
face = "plain")) +
labs(title = "Visual # 5: Relationship between Petal and Sepal Length",
subtitle = "Species level comparision",
x = "Iris Sepal Length",
y = "Iris Petal Length")
