Title: | Convert Plot to 'grob' or 'ggplot' Object |
---|---|
Description: | Convert plot function call (using expression or formula) to 'grob' or 'ggplot' object that compatible to the 'grid' and 'ggplot2' ecosystem. With this package, we are able to e.g. using 'cowplot' to align plots produced by 'base' graphics, 'ComplexHeatmap', 'eulerr', 'grid', 'lattice', 'magick', 'pheatmap', 'vcd' etc. by converting them to 'ggplot' objects. |
Authors: | Guangchuang Yu [aut, cre] |
Maintainer: | Guangchuang Yu <[email protected]> |
License: | Artistic-2.0 |
Version: | 0.1.2 |
Built: | 2024-11-01 04:24:42 UTC |
Source: | https://github.com/guangchuangyu/ggplotify |
convert plot to ggplot object
as.ggplot(plot, scale = 1, hjust = 0, vjust = 0, angle = 0, ...)
as.ggplot(plot, scale = 1, hjust = 0, vjust = 0, angle = 0, ...)
plot |
base or grid plot, or graphic generated by ggplot, lattice, etc. |
scale |
scale of the plot to be drawn |
hjust |
horizontal adjustment |
vjust |
vertical adjustment |
angle |
angle to rotate plot |
... |
additional parameters passed to as.grob |
ggplot object
Guangchuang Yu
as.ggplot(~barplot(1:10))
as.ggplot(~barplot(1:10))
convert a plot to grob object
as.grob(plot, ...) ## S3 method for class 'aplot' as.grob(plot, ...) ## S3 method for class 'oncoplot' as.grob(plot, ...) ## S3 method for class 'bbplot' as.grob(plot, ...) ## S3 method for class 'patchwork' as.grob(plot, ...) ## S3 method for class 'gglist' as.grob(plot, ...) ## S3 method for class 'expression' as.grob(plot, ...) ## S3 method for class 'formula' as.grob(plot, ...) ## S3 method for class ''function'' as.grob(plot, ...) ## S3 method for class 'ggplot' as.grob(plot, ...) ## S3 method for class 'meme' as.grob(plot, ...) ## S3 method for class 'trellis' as.grob(plot, ...) ## S3 method for class 'eulergram' as.grob(plot, ...) ## S3 method for class 'Heatmap' as.grob(plot, ...) ## S3 method for class 'upset' as.grob(plot, ...) ## S3 method for class 'pheatmap' as.grob(plot, ...) ## S3 method for class 'grob' as.grob(plot, ...)
as.grob(plot, ...) ## S3 method for class 'aplot' as.grob(plot, ...) ## S3 method for class 'oncoplot' as.grob(plot, ...) ## S3 method for class 'bbplot' as.grob(plot, ...) ## S3 method for class 'patchwork' as.grob(plot, ...) ## S3 method for class 'gglist' as.grob(plot, ...) ## S3 method for class 'expression' as.grob(plot, ...) ## S3 method for class 'formula' as.grob(plot, ...) ## S3 method for class ''function'' as.grob(plot, ...) ## S3 method for class 'ggplot' as.grob(plot, ...) ## S3 method for class 'meme' as.grob(plot, ...) ## S3 method for class 'trellis' as.grob(plot, ...) ## S3 method for class 'eulergram' as.grob(plot, ...) ## S3 method for class 'Heatmap' as.grob(plot, ...) ## S3 method for class 'upset' as.grob(plot, ...) ## S3 method for class 'pheatmap' as.grob(plot, ...) ## S3 method for class 'grob' as.grob(plot, ...)
plot |
base or grid plot, or graphic object generated by ggplot, lattice, etc. |
... |
additional parameter, mostly will be ignored. |
grob object
Guangchuang Yu
as.grob(~barplot(1:10))
as.grob(~barplot(1:10))
convert base plot to grob object
base2grob(x, envir = parent.frame())
base2grob(x, envir = parent.frame())
x |
expression or formula of base plot function call, e.g. expression(pie(1:5)) or ~plot(1:10, 1:10); or a function that plots to an R graphics device when called, e.g. function() plot(sqrt) |
envir |
environment to search variables |
grob object
Guangchuang Yu
base2grob(~plot(rnorm(10)))
base2grob(~plot(rnorm(10)))
convert grid plot to grob object
grid2grob(plot_call)
grid2grob(plot_call)
plot_call |
plot function call |
grob object
Guangchuang Yu