如何解决“MatplotlibDeprecationWarning: scipy.stats.norm.pdf"警告? [英] How to solve "MatplotlibDeprecationWarning: scipy.stats.norm.pdf" warning?
问题描述
我在我的Python代码中使用matplotlib.我收到以下警告: xxx.py:88:MatplotlibDeprecation警告:scipy.stats.norm.pdfy = 100 * mlab.normpdf(bin_middles, mu, sigma)*bin_width
我想知道问题是什么,所以我可以解决它,避免出现警告.
I am using matplotlib in my Python code. I got following warning:
xxx.py:88: MatplotlibDeprecationWarning: scipy.stats.norm.pdf
y = 100 * mlab.normpdf(bin_middles, mu, sigma)*bin_width
I was wondering what the issue is, so I can solve it and avoid warnings.
推荐答案
文档向我们介绍了matplotlib.mlab.normpdf
The documentation tells us about matplotlib.mlab.normpdf
自 2.2 版起已弃用:scipy.stats.norm.pdf
Deprecated since version 2.2: scipy.stats.norm.pdf
This translates into: Do not use this function any more, use scipy.stats.norm.pdf
instead.
因此有一个以前的代码,如
Hence a previous code like
import matplotlib.mlab as mlab
import numpy as np
x = np.linspace(-3,3)
mu = 0
sigma = 1
y = mlab.normpdf(x, mu, sigma)
现在应该阅读
import numpy as np
import scipy.stats
x = np.linspace(-3,3)
mu = 0
sigma = 1
y = scipy.stats.norm.pdf(x, mu, sigma)
这篇关于如何解决“MatplotlibDeprecationWarning: scipy.stats.norm.pdf"警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!