Although gtable could be converted into ggplot using ggplotify::as.ggplot, the output is different from the origin ggplot. For example:
library(ggplot2)
p <- ggplot(mtcars, aes(wt, mpg)) + geom_point()
g <- ggplot_gtable(ggplot_build(p))
p_new <- ggplotify::as.ggplot(p)
# origin
p + theme(aspect.ratio = 2)
# changed
p_new + theme(aspect.ratio = 2) # different figure shape from the origin one
How could I covert gtable into the same ggplot p_new as the origin one p?
You can use ggplotify::as.ggplot():
library("ggplotify")
as.ggplot(q)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With