Skip to content

subplot does not seem to handle well relatively long lists #1515

Open
@ndrubins

Description

@ndrubins

Hi,

I'm trying to use subplot in order to vertically group bar plots, sharing their x-axis.

Here are example data which have 28 groups where I'm creating a bar plot over 4 families in each and then trying to vertically combine them using subplot:

set.seed(1)
df <- data.frame(group = paste0("G",unlist(lapply(1:28,function(i) rep(i,4)))),
                 family = paste0("F",rep(1:4,28)),
                 log2n = log2(as.integer(runif(4*28,0,30))+1),
                 stringsAsFactors = F)

Creating the list of bar plots:

library(plotly)
groups <- unique(df$group)
y.range <- c(0,max(df$log2n))
plot.list <- lapply(1:length(groups),function(g){
  group.df <- dplyr::filter(df,group == groups[g])
  plot_ly(x=group.df$family,y=group.df$log2n,type='bar',name=group.df$family,color=group.df$family,showlegend=(g==length(groups))) %>%
    layout(yaxis=list(range=y.range))
})

If I try:
p <- plotly::subplot(plot.list,shareX=T,nrows=length(plot.list))

Screen Shot 2019-04-10 at 6 48 53 PM

So it seems like some sort of an overflow.

I gradually cut down on the number of plots in plot.list that I run subplot on and when reach 19 it seemed to stop 'overflowing':
p <- plotly::subplot(plot.list[1:19],shareX=T,nrows=19)
Screen Shot 2019-04-10 at 6 50 37 PM

Any idea if there's hope to get all 28 bar plots without overflowing?

Thanks a lot

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions