outliers |>
filter(.cluster_pred=="Cluster 1") |>
group_by(category,pitchType,outlier) |>
count() |> group_by(outlier) |>
mutate(pct=n/sum(n),
pct=ifelse(outlier=="#212529",-1*pct,pct)) |>
ggplot(aes(x=pitchType,y=pct,fill=outlier)) +
geom_col() +
facet_grid(category~., scales="free", switch="y", space="free_y") +
scale_y_continuous(breaks = c(-1,-.5,0,.5,1),
limits = c(-1,1),
labels=c("100%","50%","0%","50%","100%")) +
scale_fill_identity() +
coord_flip() +
labs(x="Pitch Type",
y="",
title="Proportion of Pitch Types assigned to Cluster 1") +
ggthemes::theme_hc() +
theme(strip.placement="outside",
strip.background = element_blank())