1. ggplot practice
library(ggplot2)
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
## ✓ tibble  3.1.6     ✓ dplyr   1.0.7
## ✓ tidyr   1.1.4     ✓ stringr 1.4.0
## ✓ readr   2.1.1     ✓ forcats 0.5.1
## ✓ purrr   0.3.4
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
library(ggmosaic)
plant <- iris # using built in iris data
head(plant)
##   Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 1          5.1         3.5          1.4         0.2  setosa
## 2          4.9         3.0          1.4         0.2  setosa
## 3          4.7         3.2          1.3         0.2  setosa
## 4          4.6         3.1          1.5         0.2  setosa
## 5          5.0         3.6          1.4         0.2  setosa
## 6          5.4         3.9          1.7         0.4  setosa
p1 <- ggplot(data=plant, mapping = (aes(x=Petal.Length, y=Petal.Width, fill=Petal.Length))) +
  geom_bar(stat="identity", position="dodge")+
  labs(title="Iris Petal Width and Length",
       x="Petal Width + Petal Length") #,
       #y="Petal Width")
print(p1)

p2 <- ggplot(data=plant, mapping = (aes(x=Petal.Length, y=Petal.Width, fill=Petal.Length))) +
  geom_bar(stat="identity", position="dodge",fill="mediumvioletred")+
  labs(title="Iris Petal Width and Length",
       x="Petal Width + Petal Length") #,
       #y="Petal Width")
print(p2)

p3 <- ggplot(data=plant,mapping=aes(x=Petal.Length, y=Petal.Width, color=Petal.Length)) +
  geom_point() +
  labs(title="Iris Petal Width and Length",
       x="Petal Width + Petal Length",
       y="Length (cm)",
       color = "Width or Length")

print(p3)

ggsave(plot=p3, filename="IrisScat.png",width=10,height=10,units="cm",device="png")