ggplotly bar chart not resizing after filtering

hey, can stacked bar plot resizing after filtering via legend be achieved using ggplotly?
Desired output is seen on the left side of the image.

library(ggplot2)
library(dplyr)
library(plotly)

# number of diamonds by cut and clarity (n)
cc <- count(diamonds, cut, clarity)
# number of diamonds by cut (nn)
cc2 <- left_join(cc, count(cc, cut, wt = n, name = 'nn')) %>%
  mutate(prop = n / nn)


# plot is resizing (useful for comapring sum on remaining groups)
cc2  %>%
  plot_ly(x = ~cut, y = ~prop, color = ~clarity) %>%
  add_bars() %>%
  layout(barmode = "stack")

# plot is not resizing
(cc2 %>% 
  ggplot(aes(cut, prop, fill = clarity)) +
  geom_bar(stat = 'identity')
) %>% plotly::ggplotly()

Fine for me.

image

sessionInfo()
R version 4.0.1 (2020-06-06)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19043)

other attached packages:
[1] plotly_4.9.3  dplyr_1.0.5   ggplot2_3.3.3

Does filtering (clicking SI1 and SI2 in the legend) provide a graph seen in the left? That is, I1 (dark purple) will stack on VS2 instead of keep "hanging" on the top of the graph (as seen on right graph)?
If so, what code produced it?

This topic was automatically closed 21 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.