0

I have line plots showing estimated pitch values of a sound recording across time: enter image description here

For my presentation, I'd like to suggest how, by simply reversing the x and y axes, these plots can be turned - for analysis purposes - into histograms that show how much time was spent by the sound at each pitch state (across bins of, say, 1-semitone width).

Thus, the above plot would be transformed visually by simply rotating it 90 degrees and letting the (now vertical) lines "fall" down to the x (Pitch) axis, one next to each other. I tried finding some toy example to make it more clear what I want to achieve, alas I could not find anything useful.

I can easily create these histograms, also in Matlab, but what I am unsure how to do is the animation of the vertical bars falling into alignment on the x axis. Ideal would be to find software that generates the intermediate steps for animation by perhaps doing a step-by-step interpolation between the initial plot above, and its reversed (histogram) version in which the bars already "fell"; and then exports either an animated GIF, or intermediate plots that I can then import into my presentation software (Powerpoint) to create the animation myself.

More realistically, I wonder if there is a way to use Matlab itself to create those intermediary steps between two given plots. I am happy to also try out any suggestions in Python, as long as they are provided in sufficient detail (complete beginner there!) Thanks for any help!

I should add my question also holds, more generally, for animating other plot elements too not just lines, e.g. starting from a scatter/dot plot and having the dots fall down into stacks/distributions.

5
  • 1
    Why do you need this to be an animation? I feel like 3 images (original as shown, flipped axes, and final histogram) would suffice to make your point, and be relatively trivial to make... Otherwise you're going to have to forfeit using the built in plotting functions, in favour of bodging the visuals. I say bodging because plot objects are not just floating graphics you can move around, MATLAB is designed for accurate mathematical operations over graphical manipulations.
    – Wolfie
    Oct 18, 2018 at 17:17
  • Excellent point, thank you! You're completely right - the point would be made clear enough even with the 3 plots alone. It's just I've seen an animation once in someone's presentation that did just that (animating the falling dots to transition between the flipped and the final version), and thought it made the point very nicely of exactly how the data in the histogram represents the previous raw plots. And made a note to myself to use this effect too one day, which I am trying to do now, unless it proves to take ages :)
    – z8080
    Oct 18, 2018 at 17:27
  • Note it would also be very helpful if you edited your question to provide example data for the original plot... to minimise the effort put in by anyone attempting this fairly broad question
    – Wolfie
    Oct 18, 2018 at 17:28
  • FWIW, I think the animation is more compelling if you just make gravity horizontal and drop the data to a sum pressed against the Y axis. Histograms stretching right instead of stretching up are just as readable, but if you're already providing the data in this orientation, it's best to leave it in that orientation when you go from "event instances" to "duration sum". Oct 18, 2018 at 20:32
  • @IanMacDonald: hm, you do have a point. Technically however, I'd be equally challenged to create the animation for this plot variant also :(
    – z8080
    Oct 19, 2018 at 9:08

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.