'MatplotlibDeprecationWarning' - 尝试绘制直方图时的警告



我试图使用matplotlib绘制直方图,但一直遇到这个错误:

MatplotlibDeprecationWarning: The resize_event function was deprecated in Matplotlib 3.6 and will be removed two minor releases later. Use callbacks.process('resize_event', ResizeEvent(...)) instead.

这是我的密码;关于我如何清理逻辑表达式的反馈也很受欢迎。

lower_quartile = df['2020 Population'].quantile(0.25)
mid_quartile = df['2020 Population'].quantile(0.5)
upper_quartile = df['2020 Population'].quantile(0.75)
new_data = df.loc[df['2020 Population'] > lower_quartile]
final_2020_range = new_data.loc[df['2020 Population'] < upper_quartile]
check = final_2020_range['2020 Population']
plt.hist(check)

您似乎可以在这里找到答案:https://github.com/matplotlib/matplotlib/issues/23921

简而言之:这是一个错误,将在3.6.1 中进行更正

我也面临同样的问题,我找到了一个解决方案:

import matplotlib
matplotlib.use('TkAgg')

错误仍然存在,但现在您可以看到绘图。

最新更新