ldan
ldan

Reputation: 41

How to save R base graphics as an object?

I have a chord diagram built using the circlize package. Unfortunately, it seems like there is no way to save this as an object. I would like to have the plot be an object (especially a ggplot obkect) so that I can modify some of the surrounding text and export it to xlsx. Any suggestions?

Thanks!

Upvotes: 0

Views: 1137

Answers (1)

thc
thc

Reputation: 9705

Several options from various packages:

ggplotify:

g <- as.grob(~plot(runif(10)))
grid.draw(g)

cowplot:

plot(runif(10))
p1_recorded <- recordPlot()
ggdraw(p1_recorded)

Upvotes: 2

Related Questions