I have several confusion matrices and I want to compare them. I thought it would be great to visualize the highest and lowest value for each category in a single plot. I imagine something like this (forgive me the ugly paint doodle):
For each category, there is an upper rectangle showing the highest value across all confusion matrices, the lower rectangle shows the lowest value across all confusion matrices. The color inidcates, which dataset the rectangle belongs to.
So, how can I achieve this? I figured I might bring it to work using geom_polygon(), but I never used that and I imagine it's quite some work. Is there a way which would allow me to use geom_tile() but to use triangles instead of rectangles? I saw some ggplots with rectangles which were horizontally divided into smaller rectangles, so I thought maybe there is a possibility to do triangles too?
Here would be some dummy data:
datasets <- c("Data Set 1", "Data Set 2", "Data Set 3", "Data Set 4")
df <- data.frame(
"Truth" = c(rep(c("A","B","C","D"), 8)),
"Prediction" = c(rep(c("A","B","C","D"), each = 8)),
"Type" = c(rep(rep(c("min", "max"), each = 4), 4)),
"Data_Set" = sample(datasets, 8*4, replace = TRUE),
"Value" = round(runif(8*4)*100))
Making a single plot per maximum / minimum value would be easy. For example:
ggplot(df[df$Type == "min",]) +
geom_tile(aes(x = Truth, y = Prediction, fill = Data_Set)) +
geom_text(aes(x = Truth, y = Prediction, label = Value))
But I am looking for a pretty way to combine a tileplot for the maximum and the minimum. I am also open for other ideas. I guess many people wanted to compare several confusion matrices in one plot before me?


