繁体   English   中英

如何在 Seaborn 中将条形与 x 标签居中对齐?

[英]How to center align bars to x-labels in Seaborn?

如何将第一个条形与 x 标签 CI 对齐? 太左了。 为了更加挑剔,其余的条形也向右移动。 我怎样才能将它们全部居中?

条形图

我的代码如下所示:

colors = ["coral", "sea blue"]
g = sns.FacetGrid(data=c_obs_00_pd, size=7, aspect=1.5)
g.map(sns.barplot, "Name", '% of Significant T Test', "Location", palette=sns.xkcd_palette(colors), order=['CI', '20%, Small', '20%, Large', '50%, Small', '50%, Large'])
g.map(plt.axhline, y=5.6, color="k", ls='--', lw="3")
loading_patch = mpl.patches.Patch(color='#fc5a50', label='Loading')
threshold_patch = mpl.patches.Patch(color='#047495', label='Threshold')
plt.legend(handles=[loading_patch, threshold_patch], loc='upper left', ncol=1, fontsize=14)
plt.title("Cancelout Simulation", fontsize=18)
plt.ylabel("Percent of Significant t-Tests", fontsize=18, labelpad=25)
plt.xlabel("Conditions - Latent Means Simulated as Equal", fontsize=18, labelpad=20)
plt.grid(b=True, which='minor', color='k', axis='y', linestyle='-', alpha=0.1)
plt.tick_params(axis='both', which='major', labelsize=16)
plt.minorticks_on()
plt.savefig('Cancelout-% of Sig t-Test in Equal Latent Mean.png', dpi=75)

正如评论中所指出的,条形看起来偏离中心的原因是因为您有一个色调级别没有显示在图中,即最左边的条形中没有数据。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM