gpt4 book ai didi

python - 如何修复 : MatplotlibDeprecationWarning: shading ='flat' when X and Y have the same dimensions as C is deprecated since 3. 3

转载 作者:行者123 更新时间:2023-12-04 12:18:00 31 4
gpt4 key购买 nike

我是 Python 编程的新手,但在尝试从 RAVDESS 数据集 wav 文件绘制频谱图时,我一直在与这些错误作斗争。这是代码;

`for file in range(0 , len(listOfFiles) , 1):
windows_size = 20
sample_rate , samples = wavfile.read(listOfFiles[file])
nperseg = int(round(20 * sample_rate / 1e3))
frequencies , times, spectrogram = signal.spectrogram(samples, sample_rate)
plt.pcolormesh(times, frequencies, spectrogram)
plt.imshow(spectrogram)
plt.ylabel('Frequency [Hz]')
plt.xlabel('Time [sec]')
plt.show()`
以下是错误
<ipython-input-16-dc119f345487>:14: WavFileWarning: Chunk (non-data) not understood, skipping it.
sample_rate , samples = wavfile.read(listOfFiles[file])
<ipython-input-16-dc119f345487>:14: WavFileWarning: Incomplete chunk ID: b'\x00', ignoring it.
sample_rate , samples = wavfile.read(listOfFiles[file])
<ipython-input-16-dc119f345487>:17: MatplotlibDeprecationWarning: shading='flat' when X and Y have the same dimensions as C is deprecated since 3.3. Either specify the corners of the quadrilaterals with X and Y, or pass shading='auto', 'nearest' or 'gouraud', or set rcParams['pcolor.shading']. This will become an error two minor releases later.
plt.pcolormesh(times, frequencies, spectrogram)
抱歉,我无法更好地解释错误,但我对此很陌生,任何帮助都会很棒。

最佳答案

添加 shading='auto' 将解决这个问题。
所以代码应该是plt.pcolormesh(times, frequencies, spectrogram,shading='auto' )

关于python - 如何修复 : MatplotlibDeprecationWarning: shading ='flat' when X and Y have the same dimensions as C is deprecated since 3. 3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65799736/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com