簡體   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