我使用以下代码将散点图覆盖在箱线图上:
import seaborn as sns
import matplotlib.pyplot as plt
import pandas as pd
d = {'exp_time': [80, 138, 72, 47, 95, 162, 157, 150, 147, 51, 150, 173, 77, 65], 'Group': ['y', 'n','n', 'n', 'y', 'n', 'n', 'y', 'n', 'n', 'y', 'y', 'n', 'n']}
df = pd.DataFrame(data=d)
ax = sns.boxplot(x="Group", y="exp_time", data=tips, showfliers = False)
ax = sns.swarmplot(x="Group", y="exp_time", data=tips, color=".25")
plt.show()
但是,我收到“无法输入‘组’”的错误消息。这是为什么?即使我将 Group 转换为 categoricals
df.Group.apply(str)
错误未解决。