Home > Mobile >  How to display audio at the right side of matplotlib
How to display audio at the right side of matplotlib

Time:07-14

The following code display the image and audio in the top-bottom style:

enter image description here

Here is the test code:

import librosa
import matplotlib.pyplot as plt
import IPython.display as ipd

def plot_it(name, audio, sample_rate):
    plt.figure(figsize=(8, 1))
    plt.plot(audio)
    plt.gca().set_title(name)

    plt.show()

    ipd.display(ipd.Audio(data=audio, rate=sample_rate))

Is it possible for changing the "top-bottom" style to "left-right" style for displaying the audio at the right side of the plt figure?

CodePudding user response:

You can use a enter image description here

(It is essential to close the figure, otherwise you'll have double output of the figure. This is easier to do this using the OOP than the pyplot interface, that's why I changed your matplotlib code a bit)

  • Related