Would it make sense to…

We need a clever way to display EVC and EVC. What if we did a faceted heat map where the X axis was acres, y axis was categories (cover or height) and the facets were the EVTs (top 5 or so)?

Waffle may be better!

Tutorials and websites

data prep

wimped out did in excel:

  1. took michiAllClean.csv, made pivot with:
    • evt selected for top 5 based on total acres
    • tree cover
    • acres
  2. pasted selected categories and values into new sheet
  3. cleaned up variable names
  4. using copy/paste/etc made sure that each EVT had 101 rows from 0-100
  5. removed regional modifiers (e.g., “Sub-boreal”)

NOW TRY THIS TILED HEAT MAP THINGIE

library(readr)
library(ggplot2)

evc_evt5 <- read_csv("evc_evt5.csv", col_types = cols(percent = col_number()))


# order EVTs
evc_evt5$evt  <- factor(evc_evt5$evt, levels = c("Northern Hardwoods Forest","Alkaline Conifer-Hardwood Swamp", "Conifer Acidic Swamp and Treed Poor Fen", "Mesic Balsam Fir-Spruce Forest", "Pine-Hemlock Forest"))

evc_evt5[order(evc_evt5$evt), ]
## # A tibble: 505 x 3
##    evt                       cover_percent percent
##    <fct>                             <dbl>   <dbl>
##  1 Northern Hardwoods Forest             0       0
##  2 Northern Hardwoods Forest             1       0
##  3 Northern Hardwoods Forest             2       0
##  4 Northern Hardwoods Forest             3       0
##  5 Northern Hardwoods Forest             4       0
##  6 Northern Hardwoods Forest             5       0
##  7 Northern Hardwoods Forest             6       0
##  8 Northern Hardwoods Forest             7       0
##  9 Northern Hardwoods Forest             8       0
## 10 Northern Hardwoods Forest             9       0
## # ... with 495 more rows
#plot
evc_th1 <-  ggplot(evc_evt5 ,aes(x=cover_percent ,y=evt ,fill=percent))+
      geom_tile()

evc_th1 

Not bad…now to customize

evc_th2  <- ggplot(evc_evt5 ,aes(x=cover_percent ,y=evt ,fill=percent))+
  #add border white colour of line thickness 0.25
  geom_tile(colour="white",size=0.25)+
  #remove x and y axis labels
  labs(x="Canopy Cover (0-100%)",y="")+
  #remove extra space
  scale_y_discrete(expand=c(0,0))+
  #define new breaks on x-axis
  #scale_x_discrete(breaks=c("10", "20", "30", "40", "50", "60", "70", "80", "90")) +
  #set a base size for all fonts
  theme_grey(base_size=8)+
  #theme options
  theme(
    #bold font for legend text
    legend.text=element_text(face="bold"),
    #set thickness of axis ticks
    axis.ticks=element_line(size=0.4),
    #remove plot background
    plot.background=element_blank(),
    #remove plot border
    panel.border=element_blank())

evc_th2 

ACK those colors and no x-axis

evc_th3 <-
evc_th2 + 
  scale_fill_gradient(low="white", high="darkgreen") +
  scale_x_continuous(breaks = seq(from = 0, to = 100, by = 10)) 
  

evc_th3

Getting close. Need to remove grey border, change fonts (family and size), remove legend, add a title and subtitle, x-axis title

evc_th4 <-
  evc_th3 +
  theme_bw(base_size = 14) +
  #theme(legend.position = "none") +
  scale_y_discrete(limits = rev(unique(sort(evc_evt5$evt )))) +
  labs(title = "Tree canopy cover for 5 most prevalent ecosystems",
              subtitle = "",
              caption = "LANDFIRE 2016 Existing Vegetation Cover data. ") +
  labs(fill = "Percent of \nEcosystem")
## Scale for 'y' is already present. Adding another scale for 'y', which will
## replace the existing scale.
evc_th4 

Try to add acres, left justify title.subtitle

evt_labels <- c("Pine-Hemlock Forest (35,820ac)",
                "Mesic Balsam Fir-Spruce Forest (36,791ac)",
                "Conifer Acidic Swamp and Treed Poor Fen (44,560ac)",
                "Alkaline Conifer-Hardwood Swamp (52,118ac)", 
                 "Northern Hardwoods Forest (332,434ac)")
                  
  
  
evc_th5 <- evc_th4 +
  scale_y_discrete(limits = rev(unique(sort(evc_evt5$evt ))), labels= evt_labels,) +
theme(plot.caption = element_text(hjust = 0, face= "italic"), #Default is hjust=1
        plot.title.position = "plot", #NEW parameter. Apply for subtitle too.
        plot.caption.position =  "plot")
## Scale for 'y' is already present. Adding another scale for 'y', which will
## replace the existing scale.
# didn't need to have "rev" in that last line...could've had labels in correct order to begin with
evc_th5