yardstick
yardstick copied to clipboard
Access underlying data of `autoplot()` objects
The autoplot()
functions are great out of the box for quick insights, but I wish there was a way to access the underlying data used to generate said plots. For example the autoplot.conf_mat()
does the data prep and the plotting. If users could access the underlying data we could generate custom visualizations.
The data prep isn't trivial either especially for the "mosaic" type plots.
https://github.com/tidymodels/yardstick/blob/5f1068ff8bdd402416996da35352526a80c4c966/R/conf_mat.R#L343-L379
It would be great if there was an optional arg to just return the data or even a separate user facing function. Hadley describes this as a best practice here.
7.5.3 Isolate side effects Creating plots and printing output to the console are two other ways of affecting the global R environment. Often you can’t avoid these (because they’re important!) but it’s good practice to isolate them in functions that only produce output. This also makes it easier for other people to repurpose your work for new uses. For example, if you separate data preparation and plotting into two functions, others can use your data prep work (which is often the hardest part!) to create new visualisations.
Let me know what your opinions are. I know there's a bunch of different autoplot()
functions so any change probably warrants further discussion. Thank you!
I know I would love this, because I will end up overloading some of these methods when I want to use them in blog posts, etc.
I would use this feature as well to apply my fill color scale, along with prismatic to flip the color of the text labels on the dark tiles.