简体   繁体   中英

How to center align bars to x-labels in Seaborn?

How do I align the first bar with the x-label CI? It is too left. To be even more pickier, the rest of the bars are shifted to the right as well. How can I center all of them?

条形图

My code looks like this:

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)

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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