title: Multiple density plot with plotly in R
body: <p>I really like this python example:<a href="https://plot.ly/python/distplot/" rel="nofollow noreferrer">https://plot.ly/python/distplot/</a> scroll to Plot Multiple Datasets. I would expect the exact same thing is available for R, but it's not documented. Does this mean it's not possible? I came across this example <a href="https://community.plot.ly/t/r-plotly-overlay-density-histogram/640/4" rel="nofollow noreferrer">https://community.plot.ly/t/r-plotly-overlay-density-histogram/640/4</a> which I find far less nice.
  This doesn't work but would give an idea about the data I use.</p>
  
  <pre><code># Add histogram data
  x1 = data.table(a=rnorm(n = 200,mean = 0,sd = .1), by='Group1')
  x2 = data.table(a=rnorm(n = 200,mean = 1,sd = .15), by='Group2')
  x3 = data.table(a=rnorm(n = 200,mean = 2,sd = .2), by='Group3')
  x4 = data.table(a=rnorm(n = 200,mean = 3,sd = .25), by='Group4')
  
  agg &lt;- rbind(x1,x2,x3,x4)
  plot_ly(data = agg, type = "histogram",histnorm, name = "Histogram",group_by='by')
  plot_ly(data = agg, type = "density",histnorm, name = "Density",group_by='by')
  </code></pre>