Beispiel #1
0
def plot_spectrum(ax1, ax2):
    spectrum, spec_extent = spectrum_data.get(), spectrum_data.get_extent()
    z = 10. * np.log10(spectrum)
    z = np.flipud(z)

    ax1.imshow(z, plt.magma(), extent=spec_extent, aspect='auto')
    ax1.figure.canvas.draw()

    ax2.imshow(z, plt.magma(), extent=spec_extent, aspect='auto')
    ax2.plot(time, result, color='g')
    ax2.set_ylim(bottom=0, top=512)
    ax2.figure.canvas.draw()
Beispiel #2
0
def plot_spectrum(spectrum, extent, filename):
    z = 10. * np.log10(spectrum)
    z = np.flipud(z)
    plt.imshow(z, plt.magma(), extent=extent, aspect='auto')
    plt.gcf().set_size_inches(15, 5)
    plt.savefig(filename, dpi=100)
    plt.close()
Beispiel #3
0
def ploter(columned_file):
    '''
        this function will plot 4D dots
    '''
    fig = plt.figure()
    ax = fig.add_subplot(111, projection='3d')

    x = columned_file[0]
    y = columned_file[1]
    z = columned_file[2]
    c = columned_file[3]

    img = ax.scatter(x, y, z, c=c, cmap=plt.magma())
    fig.colorbar(img)
    plt.show()
#import the plt and wavfile modules
import matplotlib.pyplot as plt
from scipy.io import wavfile
import os
import argparse

# argparser
parser = argparse.ArgumentParser(
    description="Plot audio spectrogram for .wav file")
parser.add_argument("audio_file", type=str, help=".wav file path")
args = parser.parse_args()

file_path, file_name = os.path.split(args.audio_file)
file_path = os.path.join(file_path, file_name)

# Read the wav file (mono)
samplingFrequency, signalData = wavfile.read(file_path)

# Plot the signal read from wav file
plt.title(f'Spectrogram of {file_name}')
plt.subplot(111)
plt.specgram(signalData, Fs=samplingFrequency)
plt.magma()
plt.xlabel('Time')
plt.ylabel('Frequency')
plt.show()