```{r, child="exercise-setup.Rmd"}
```
```{r setup, include = FALSE}
library(agridat) # for datasets
library(tidyverse) # contains ggplot2, dplyr, tidyr, etc
library(scales)
library(colorspace)
knitr::opts_chunk$set(
  fig.path = "images/part1-exercise-04/",
  class.source = "solution"
)
```

## Exercise 4.1

```{r part1-exercise-01}
ggplot(hazell.vegetables, aes(year, celery, fill = celery > 0)) + 
  geom_col(show.legend = FALSE) + 
  geom_hline(yintercept = 0) + 
  scale_y_continuous(labels = dollar) + 
  labs(y = "Gross profit", x = "Year",
       title = "Celery", fill = "Profit") +
  scale_fill_manual(values = c("#ff1a1a", "#008000")) +
  scale_x_discrete(labels = 1:6) + 
  theme(axis.text = element_text(size = 18),
        axis.text.y = element_text(face = "italic"),
        axis.title = element_text(size = 22),
        plot.title = element_text(size = 30, face = "bold",
                                  margin = margin(b = 40),
                                  hjust = -0.8),
        panel.background = element_rect(fill = "transparent"),
        axis.line = element_line(color = "black",
                                 size = 1.3))
```

## Exercise 4.2

```{r part1-exercise-02}
ggplot(heady.fertilizer, aes(P, yield)) +
geom_point() + facet_wrap(~crop, scale = "free_y") + 
  geom_smooth() + 
  labs(x = "Phosphorous (pounds/acre)",
       y = "Yield"
       ) + 
  theme(plot.background = element_rect(fill = "#CCDFDD", color = "black"),
        strip.background = element_rect(fill = "transparent"),
        panel.background = element_rect(fill = "transparent"))
```

## Exercise 4.3

```{r part1-exercise-03}
ggplot(wallace.iowaland, aes(long, lat, color = yield)) + geom_point(size = 6) +
  scale_color_continuous_diverging(palette = "Green-Brown", rev = TRUE, mid = mean(wallace.iowaland$yield)) + 
  labs(y = "Latitude", x = "Longitude", color = "Yield") +
  theme(rect = element_rect(fill = "black"),
        text = element_text(color = "white"),
        panel.background = element_rect(fill = "transparent"),
        panel.grid.minor = element_line(linetype = "dashed"),
        axis.text = element_text(color = "gray"))
```

