jolars / eulerr

Area-Proportional Euler and Venn Diagrams with Ellipses
https://jolars.github.io/eulerr/
GNU General Public License v3.0
129 stars 18 forks source link

Plotting euler diagram overrides multi-panel layout #98

Closed ericminikel closed 2 years ago

ericminikel commented 2 years ago

Plotting an euler object takes up the entire plot window, overriding any prior specification of a multi-panel layout. Example:

library(eulerr)
fit = euler(list(a=1:3, b=2:4))
par(mfrow=c(1,2))
plot(1,1)
plot(fit, usr=par()$usr)

Intended behavior: scatter plot at left, euler diagram at right. Actual behavior: euler diagram fills whole window, scatter plot not visible.

Same occurs if layout is used instead of par(mfrow):

library(eulerr)
fit = euler(list(a=1:3, b=2:4))
layout(matrix(1:2, nrow=1, byrow=T))
plot(1,1)
plot(fit, usr=par()$usr)

Is this the intended behavior? Perhaps an unavoidable consequence of using grid::grid.layout in eulerr:error_plot? Apologies if this is a silly question, I looked through the docs and didn't see any obvious acknowledgment of whether this was known or intended. I'm trying to use an Euler diagram as one panel in a multi-panel figure for a scientific manuscript, and so far the workaround I have figured out is to go through the analog hole — writing out the plot as a png, then reading it back in and rendering the raster. Works well enough but obviously not elegant : )

Thank you for this amazing package.

jolars commented 2 years ago

layout() is for base R graphics but eulerr uses grid graphics, so I don't think you can use layout() here and definitely not par(mfrow). Try gridExtra::grid.arrange() or maybe the patchwork package will work too actually.