【发布时间】:2021-04-12 07:49:14
【问题描述】:
当我运行这段代码时:
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
import pandas as pd
values = np.random.normal(loc=3.0,scale=1.0,size=50000)
df_FLIM = pd.DataFrame(values, columns=['Values'])
sns.set(font_scale=1.5, rc={'axes.facecolor':'pink','figure.facecolor':'white'})
f, (ax_box, ax_hist) = plt.subplots(2, sharex=True, gridspec_kw={"height_ratios": (.15, .85)})
sns.boxplot(df_FLIM["Values"], ax=ax_box, color='red')
sns.distplot(df_FLIM["Values"], ax=ax_hist, color='red')
ax_box.set(xlabel='')
plt.tight_layout()
plt.show()
我得到这个输出:
还有这些弃用警告:
C:\Users\lopez\AppData\Local\Continuum\lib\site-packages\seaborn_decorators.py:36:FutureWarning:将以下变量作为关键字 arg 传递:x。从版本 0.12 开始,唯一有效的位置参数将是 data,并且在没有显式关键字的情况下传递其他参数将导致错误或误解。
警告.warn(
C:\Users\lopez\AppData\Local\Continuum\lib\site-packages\seaborn\distributions.py:2551: FutureWarning: distplot 是一个已弃用的函数,将在未来的版本中删除。请调整您的代码以使用displot(具有类似灵活性的图形级函数)或histplot(直方图的轴级函数)。
warnings.warn(msg, FutureWarning)
我可以通过在 sns.boxplot 和“sns.displot”中使用“data=”而不是“sns.distplot”来消除这些警告,但是我无法得到完全相同的数字。你能告诉我如何摆脱这些警告,同时获得完全相同的输出吗?
【问题讨论】: