title: plotly stacked bar chart with over 100 categories
body: <p>I have a dataset that contains over 100 categories. If I am going to plot it, I have to write over 100 lines code for it. Here is the example from plotly official website: </p>
  
  <pre><code>library(plotly)
  Animals &lt;- c("giraffes", "orangutans", "monkeys")
  SF_Zoo &lt;- c(20, 14, 23)
  LA_Zoo &lt;- c(12, 18, 29)
  data &lt;- data.frame(Animals, SF_Zoo, LA_Zoo)
  p &lt;- plot_ly(data, x = ~Animals, y = ~SF_Zoo, type = 'bar', name = 'SF Zoo') %&gt;%
  add_trace(y = ~LA_Zoo, name = 'LA Zoo') %&gt;%
  layout(yaxis = list(title = 'Count'), barmode = 'stack')
  </code></pre>
  
  <p>As you can see, if I have over 100 zoos that are going to be plotted, I need to write <code>add_trace</code> for over 100 times, which is inefficient. Does anyone know of ways to simplify it? I tried using <code>for</code> loop but I failed.</p>
  
  <p>Or if anyone know how to use ggplotly to transfer a ggplot to an interactive format, it will also solve my problem. The plot produced by ggplot is a stacked grouped bar chart which x-axis have 10 <code>facet_grid</code> and about 100 categories in each grid. I tried using ggplotly directly and save it as an <code>.html</code>, however the plot's scale is very weird. It should looks like a rectangular with width about 40 and height about 8, but in <code>html</code>, it just shows like a square which is unreadable.</p>