Package 'ggplotify'

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

Help Index


as.ggplot

Description

convert plot to ggplot object

Usage

as.ggplot(plot, scale = 1, hjust = 0, vjust = 0, angle = 0, ...)

Arguments

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

Value

ggplot object

Author(s)

Guangchuang Yu

Examples

as.ggplot(~barplot(1:10))

as.grob

Description

convert a plot to grob object

Usage

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, ...)

Arguments

plot

base or grid plot, or graphic object generated by ggplot, lattice, etc.

...

additional parameter, mostly will be ignored.

Value

grob object

Author(s)

Guangchuang Yu

Examples

as.grob(~barplot(1:10))

base2grob

Description

convert base plot to grob object

Usage

base2grob(x, envir = parent.frame())

Arguments

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

Value

grob object

Author(s)

Guangchuang Yu

Examples

base2grob(~plot(rnorm(10)))

grid2grob

Description

convert grid plot to grob object

Usage

grid2grob(plot_call)

Arguments

plot_call

plot function call

Value

grob object

Author(s)

Guangchuang Yu