Add extract_plot_data() and fill value to autoplot() for type = "mosaic"#248
Add extract_plot_data() and fill value to autoplot() for type = "mosaic"#248joeycouse wants to merge 1 commit intotidymodels:mainfrom
extract_plot_data() and fill value to autoplot() for type = "mosaic"#248Conversation
extract_plot_data() and fill argument to autoplot() for type = "mosiac"extract_plot_data() and fill value to autoplot() for type = "mosiac"
extract_plot_data() and fill value to autoplot() for type = "mosiac"extract_plot_data() and fill value to autoplot() for type = "mosaic"
|
Is there some existing generic we should use for this, rather than making a new one? |
|
The only function I'm aware of that achieves something similar is the library(tidymodels)
#> Registered S3 method overwritten by 'tune':
#> method from
#> required_pkgs.model_spec parsnip
data("two_class_example")
two_class_example %>%
conf_mat(truth, predicted) %>%
autoplot() %>%
ggplot_build() %>%
pluck(1)
#> [[1]]
#> fill xmin xmax ymin ymax PANEL group colour size linetype
#> 1 #4f58bd 0.0 258.0 0.0000000 -0.8798450 1 1 NA 0.5 1
#> 2 grey70 0.0 258.0 -0.8898450 -1.0100000 1 2 NA 0.5 1
#> 3 grey70 260.5 502.5 0.0000000 -0.2066116 1 2 NA 0.5 1
#> 4 #4f58bd 260.5 502.5 -0.2166116 -1.0100000 1 1 NA 0.5 1
#> alpha
#> 1 0.9
#> 2 0.9
#> 3 0.9
#> 4 0.9Created on 2021-12-17 by the reprex package (v2.0.1) |
|
I don't think that it is a good idea to make a new generic. The That would be enough to get data for the heatmap but the mosaic plot would need some additional, non-tabular data. So, I propose:
I don't think that we need @DavisVaughan and @juliasilge how does that sound? |
|
I think this sounds like a good way to go 👍 |
Resolves part of #240
Just putting this out there to get your thoughts on the interface. I've implemented an
extract_plot_data()function for the confusion matrix class which returns a list with the relevant plot data.Would need to be extended for other
autoplot()use cases e.g. roc_curve, etc. If you think this is something worth merging I can put together the other methods. Just wanted to get y'alls take before putting more effort into this. Thanks!New

autoplot(type = 'mosaic')correct prediction boxes filled with a light blueCreated on 2021-12-10 by the reprex package (v2.0.1)