连接3个不同的数据集用于绘图

时间:2017-03-13 23:01:24

标签: python numpy matplotlib

我目前在理解连接三个numpy矩阵如何导致数据更改时遇到问题。三个numpy矩阵包含应在视频中显示的数据。

静: enter image description here 三角洲: enter image description here delta_delta: enter image description here

但不知何故,当我连接它们[static delta delta_delta]并制作相同的图时,它看起来像这样:

enter image description here

为什么数据集在最后一个中变得腐败?这是我如何连接并制作图。

import os
import sys
from os import listdir
from os.path import isfile, join
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import seaborn as sb
import matplotlib
from matplotlib import cm
from PIL import Image
from python_speech_features import logfbank
from python_speech_features import delta
import scipy.io.wavfile as wav
import librosa


        y,sr = librosa.load(fp,sr=16000)  #fp being path to audio file

        static_data = logfbank(y,sr,nfilt=13,preemph=0)
        delta_data = delta(static_data,1)
        delta_delta_data = delta(static_data,2)

        output_hstacked = np.concatenate((static_data,delta_data,delta_delta_data),axis=0)
        print output_hstacked.shape
        Y =  np.array(range(0,output_hstacked.shape[1]))
        X =  np.array(range(0,output_hstacked.shape[0]))
        X,Y = np.meshgrid(X, Y)
        plt.pcolormesh(X,Y,output_hstacked.T,cmap=cm.jet)
        plt.xlabel('Frames(s)')
        plt.ylabel('Frequency(Hz)')
        plt.title('MFSS features of ' + filename)
        #plt.yscale('log')
        plt.colorbar()
        #plt.show()
        plt.savefig(spectogram_path_test+"/"+modified_name+"_stacked.png")
        plt.close()

        Y =  np.array(range(0,static_data.shape[1]))
        X =  np.array(range(0,static_data.shape[0]))
        X,Y = np.meshgrid(X, Y)
        plt.pcolormesh(X,Y,static_data.T,cmap=cm.jet)
        plt.xlabel('Frames(s)')
        plt.ylabel('Frequency(Hz)')
        plt.title('MFSS features of ' + filename)
        #plt.yscale('log')
        plt.colorbar()
        #plt.show()
        plt.savefig(spectogram_path_test+"/"+modified_name+"_static.png")
        plt.close()


        plt.pcolormesh(X,Y,delta_data.T,cmap=cm.jet)
        plt.xlabel('Frames(s)')
        plt.ylabel('Frequency(Hz)')
        plt.title('MFSS features of ' + filename)
        #plt.yscale('log')
        plt.colorbar()
        #plt.show()
        plt.savefig(spectogram_path_test+"/"+modified_name+"_delta.png")
        plt.close()


        plt.pcolormesh(X,Y,delta_delta_data.T,cmap=cm.jet)
        plt.xlabel('Frames(s)')
        plt.ylabel('Frequency(Hz)')
        plt.title('MFSS features of ' + filename)
        #plt.yscale('log')
        plt.colorbar()
        #plt.show()
        plt.savefig(spectogram_path_test+"/"+modified_name+"_delta_delta.png")
        plt.close()

可以找到音频文件here

0 个答案:

没有答案