当我尝试在 jupyter 笔记本中使用 seaborn 绘制双轴图时遇到问题重要提示:该代码在 Python 2 上运行得很好。
使用 anaconda 升级到 Python 3 后,我收到以下错误消息:
/Users/enyi/opt/anaconda3/lib/python3.7/site-packages/seaborn/categorical.py:3720: UserWarning: catplot is a figure-level function and does not accept target axes. You may wish to try countplot
warnings.warn(msg, UserWarning)
这是我的代码的输出图像:
My code:
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
df = pd.read_csv('tips.csv')
fig, ax = plt.subplots(1,2,figsize = (10,5))
sns.catplot(x='sex', hue = 'group', data= df, kind = 'count', ax=ax[0])
sns.catplot(x='sex', y='conversion',hue = 'group', data= df, kind = 'bar',ax=ax[2])
plt.show()