I'm making a column graph of building energy consumption. The x axis is ordered by construction year and bldg name, y axis is energy metric, and I'm trying to make the width of each column proportional to the square footage. When I run the geom_col without assigning width, the x axis labels line up perfectly well. When I add the calls for width and for position_dodge to eliminate overlap (seen below), the labels bunch up in the center. Any help or direction to resources would be greatly appreciated.
library(tidyverse)
help.data <- data.frame(
stringsAsFactors = FALSE,
row.names = c("1", "6", "9", "16", "18"),
bName = c("AEROSPACE/MECHANICAL ENG",
"AHSC","ANTHROPOLOGY","APACHE HALL","ARBOL DE LA VIDA"),
constYr = c(1997, 1968, 1962, 1957, 2009),
gsf = c(184586, 460019, 38906, 30876, 234455),
bldgType = c("Academic","Medical",
"Academic","Dormitory","Dormitory"),
eui = c(214.404397950007,
526.612007183703,33.4818633521822,86.3320853089779,79.3320687466678)
)
ggplot() + geom_col(data = help.data,
aes(x = reorder(bName, constYr), y = eui, fill = bldgType),
width = help.data$gsf,
position_dodge2(preserve = c("total"))) +
ggtitle("Energy Use Indices - Width by gsf") +
labs(x = NULL, y = bquote('EUI (kBTU/gsft)')) +
theme(axis.text.x = element_text(angle = 90, size = 7, hjust = 1),
plot.title = element_text(hjust = 0.5))
Created on 2020-03-12 by the reprex package (v0.3.0)