Adjust facetted plot strip width and 'dodged' bar width in plotly object?

Following code produce expected bar and facet_strip width in ggplot2 figure. But after it is converted to plotly object, bar width and strip width collapsed. How can I adjust it?

Expected

  • strip width should be proportinal to (number of Sample in each Group)
  • each bar width should be proportional to 1/(number of N)

collapsed in plotly object

df <- tibble(Group=c('A', 'A', 'A', 'B', 'C', 'C', 'C', 'C', 'C', 'D', 'D', 'D', rep('E', 10)),
             Sample=c('S1', 'S1', 'S1', 'S2', 'S3', 'S4', 'S5', 'S5', 'S5', 'S8', 'S8', 'S9', sprintf('S%s', seq(10, 19))),
             Value=seq(1, 22),
             N=factor(c(1, 2, 3, rep(1, 3), 1, 2, 3, 1, 2, 1, rep(1, 10))))

## ggplot show plot as expected
## - strip width should be proportinal to (number of Sample in each Group)
## - each bar width should be proportional to 1/(number of N)
df %>%
    ggplot(aes(x=Sample, y=Value, fill=N)) +
    geom_col(position='dodge') +
    facet_row(~Group, scales='free_x', space='free') +
    theme()-> g

## plotly does not show plot as expected
## - same strip width
htmlwidgets::saveWidget(ggplotly(g), './example.html')


This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.