Skip to content

subplot() fails to plot 6 plots in a 2 rows x 4 columns grid #2400

Open
@louievdl

Description

I want to use subplot function to plot 6 ggplots in a 2 rows x 4 columns grid.

Here is a reproducible example:

figlist <- list()
for (i in 1:6) figlist[[i]] <- ggplot(data.frame(a = 1:3,b = 4:6), aes(a,b)) + geom_point()
subplot(figlist, nrows = 2, widths = rep(0.25,4))

This generates "Error: The length of the widths argument must be equal to the number of columns"

Looking into the code of subplots.R, the subplot function accepts arguments nrows, widths and heights, which appear to be passed through to get_domains.

The problem is that get_domains calculates ncols ignoring length(widths) and then generates an error when these don't match.

I would have expected get_domains to calculate ncols only if widths was not supplied.

I hope this helps.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions