0

I would like to create an animated histogram in R using plotly sliders. A segment of each row in the dataframe should equate to a single frame of the animation. I assumed this would be possible by using the 'frame' argument. However, it seems that the histogram plot is unable to accept dataframes as an input:

   fig <-plot_ly(x=d[,first_resistance_column:last_resistance_coluimn],type="histogram",frame=~d[disp_col]) 

I would need to use unlist to actually get a histogram plot to show up, at which point I can't use the frame argument because the input data is no longer a dataframe:

   fig <-plot_ly(x=unlist(d[,first_resistance_column:last_resistance_coluimn]),type="histogram",frame=~d[disp_col]) 

Does anyone know how I can accomplish this? It seems like this is not possible with the way that plotly histograms work in R.

  • It looks like you're fairly new to SO; welcome to the community! It would be good to see an example of what you want. You could try to create a graph of what one of these animation frames looks like and a second graph of what you might want the second frame to look like to give us an idea of what you are looking for. Make sure that you make these examples reproducible, too. This includes sample data like the output from `dput(head(dataObject)))` and any libraries you are using. Check it out: [making R reproducible questions](https://stackoverflow.com/q/5963269). – Kat Feb 23 '22 at 18:28

0 Answers0