python - Seaborn猫图: change position on x axis

标签 python matplotlib jupyter-notebook seaborn

我正在绘制两个相互重叠的seaborn分类图(点图和群图),只是不知道如何更改其中一个的x轴位置(即我的特定情况下的群图),所以这些图不是重叠的,而是“并排”(即理想情况下,我希望将各个数据点放在平均值和 ci 的右侧)。

这是生成绘图的代码:

import seaborn as sns

# set style and font size
sns.set(style='white', rc={'figure.figsize':(6,6)}, font_scale=1.3)

# plot means as points with confidence intervals
a = sns.pointplot(x='Group',
                  y='RT',
                  data=data,
                  estimator= np.mean,
                  capsize=.2,
                  join=False,
                  color='black',
                  size=12)

# plot individual data points as swarmplot
b = sns.swarmplot(x='Group',
                  y='RT',
                  data=data,
                  size=8,
                  alpha=0.8)

最佳答案

您可以将轴句柄提供给sns

我不确定这是否是你想要的!

import seaborn as sns
sns.set(style="whitegrid")
tips = sns.load_dataset("tips")

fig,ax =plt.subplots(1,2,figsize=(15,7))
sns.swarmplot(x="day", y="total_bill", data=tips,
              ax= ax[1])

sns.pointplot(x='day',
              y='total_bill',
              data=tips,
              estimator= np.mean,
              capsize=.2,
              join=False,
              color='black',
              size=12,ax=ax[0])

enter image description here

关于python - Seaborn猫图: change position on x axis,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54379159/

相关文章:

python pandas 重新索引删除 0.0 处的数据

python - Jupyter Notebook在启动Python内核时自动导入模块

python - Keras 进度条不适用于 Windows 10

python - 如何根据缩进解析 block

python - 使用 Python re 转换注释//with/*

python - 无法获取不和谐公会/服务器/ channel 成员

python - Apache 与 Django/Matplotlib 应用程序一起挂起

python - 艰难地学习 Python ex39

python - 超出matplotlib中的范围时绘制线条或颜色区域

python - 无法为 AWS Sagemaker 实例安装 toc2 笔记本扩展(生命周期配置)