#Justify angled axis text on "top" axis
library(tidyverse)
## -- Attaching packages --------------------------------------- tidyverse 1.3.1 --
## v ggplot2 3.3.5     v purrr   0.3.4
## v tibble  3.1.4     v dplyr   1.0.7
## v tidyr   1.1.4     v stringr 1.4.0
## v readr   2.0.2     v forcats 0.5.1
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
library(ggplot2)
sales <- 
  tibble(store = rep(c("ABC", "DEF", "GHI"), each = 2),
         metric = factor(rep(c("sales", "satisfaction"), 3),
                         # levels = c("sales", "satisfaction")),
                         levels = c("satisfaction", "sales")),
         risk = factor(c("medium", "low", "low", "low", "high", "medium"),
                       levels = c("low", "medium", "high")),
         value = signif(runif(6, 0, 100), 4))

ggplot(sales, aes(store, metric)) +
  geom_tile(aes(fill = risk), color = "grey50") +
  scale_fill_manual(values = c("green", "yellow", "red")) +
  scale_x_discrete(position = "top") +
  theme_minimal() + 
  theme(axis.title = element_blank(), 
        axis.text.x = element_text(angle = 90, hjust = 1),
        legend.position = "none") +
  geom_text(aes(label = value))

ggplot(sales, aes(store, metric)) +
  geom_tile(aes(fill = risk), color = "grey50") +
  scale_fill_manual(values = c("green", "yellow", "red")) +
  scale_x_discrete(position = "top") +
  theme_minimal() + 
  theme(axis.title = element_blank(), 
        axis.text.x = element_text(angle = 90),
        axis.text.x.top = element_text(vjust = 0.5),
        legend.position = "none") +
  geom_text(aes(label = value))

##https://stackoverflow.com/questions/59202780/justify-angled-axis-text-on-top-axis
#https://github.com/tidyverse/ggplot2/issues/1878