首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何修复: MatplotlibDeprecationWarning: shading='flat‘when X和Y具有与C相同的尺寸自3.3起已弃用

如何修复: MatplotlibDeprecationWarning: shading='flat‘when X和Y具有与C相同的尺寸自3.3起已弃用
EN

Stack Overflow用户
提问于 2021-01-20 05:24:26
回答 3查看 4.8K关注 0票数 5

我是python编程的新手,但在尝试从RAVDESS数据集wav文件绘制光谱图时,我已经与这些错误作了最长时间的斗争。这是代码;

代码语言:javascript
复制
`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()`

以下是错误

代码语言:javascript
复制
<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)

很抱歉,我不能更好地解释这些错误,但我是新手,任何帮助都将是令人惊讶的。

EN

回答 3

Stack Overflow用户

发布于 2021-04-11 18:14:51

Add shading='auto'将解决此问题。

所以代码应该是plt.pcolormesh(times, frequencies, spectrogram,shading='auto' )

票数 6
EN

Stack Overflow用户

发布于 2021-05-06 00:59:36

Add shading='auto'将解决此问题。

所以代码应该是

代码语言:javascript
复制
plt.pcolormesh(times, frequencies, spectrogram,shading='auto' )
票数 3
EN

Stack Overflow用户

发布于 2021-03-30 00:43:46

我解决了更改rcparams:plt.rcParams['pcolor.shading'] ='nearest'的问题。希望这能对某些人有所帮助。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65799736

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档