Exercise 4.1

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

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"))
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
## Warning: Removed 192 rows containing non-finite values (stat_smooth).
## Warning: Removed 192 rows containing missing values (geom_point).