You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
autoplot looks like great fun to play around with, but I see two major issues:
Little help for it seems to be easily available online
The documentation contains no examples whatsoever
I believe that adding some examples to its documentation would greatly improve it. At present, the user is largely left to guess what sort of inputs it will accept.
The text was updated successfully, but these errors were encountered:
I think this is a good idea, but the problem is that ggplot2 doesn't include any of the actual method implementation. So, I'm afraid this is difficult to do within ggplot2's document.
I think a vignette might be overdoing it a bit, but it probably could get a separate docpage together with autolayer() and maybe fortify(). In the example section, you could simply implement dummy methods for a matrix or something, see below.
library(ggplot2)
#> Warning: package 'ggplot2' was built under R version 4.3.1mtx<-matrix(1:12, 3, 4)
# Matrix as tidy datafortify.matrix<-function(model, ...) {
dims<- dim(model)
data.frame(
row= as.vector(.row(dims)),
col= as.vector(.col(dims)),
value= as.vector(model)
)
}
ggplot(mtx, aes(col, row, fill=value)) +
geom_raster()
# Converting matrices to a raster layerautolayer.matrix<-function(object, ...) {
# We can use `data = object` here because we've defined a `fortify()`# method above
geom_raster(aes(x=col, y=row, fill=value), data=object, ...)
}
ggplot() + autolayer(mtx)
# Converting matrices to a plotautoplot.matrix<-function(object, ...) {
ggplot(...) +
autolayer(object) +# Adding a scale for the matrix
scale_fill_viridis_c()
}
autoplot(mtx)
autoplot
looks like great fun to play around with, but I see two major issues:I believe that adding some examples to its documentation would greatly improve it. At present, the user is largely left to guess what sort of inputs it will accept.
The text was updated successfully, but these errors were encountered: