I would like to add a fill aesthetic to an autoplot function. Specifically, to the autoplot.conf_mat function from the yardstick package.
library(tidyverse)
library(tidymodels)
data("hpc_cv")
cm <- hpc_cv %>%
filter(Resample == "Fold01") %>%
conf_mat(obs, pred)
cm
#> Truth
#> Prediction VF F M L
#> VF 166 33 8 1
#> F 11 71 24 7
#> M 0 3 5 3
#> L 0 1 4 10
autoplot(cm, type = "mosaic")

Created on 2020-11-20 by the reprex package (v0.3.0)
QUESTION: How can I add a fill aesthetic to either the Truth or Prediction factor? That is, add some color to the different categories.
I have tried + scale_fill_manual and other variants, but I do not believe a fill aesthetic is being utilized in the autoplot call.
I'll show you two ways to get the result you want:
autoplot1. WITH A CUSTOM FUNCTION
The function that
autoplotcalls iscs_mosaic.You can rewrite that function to add the labels you need, in this way:
2. WITH AUTOPLOT
You can do it directly with
autoplottoo, but it's tricky and not really readable or maintainable in my opinion.