Pyplot - Invert Y labels without inverting bar cha

2019-05-28 16:42发布

问题:

I have a factorplot using seaborn:

import seaborn as sns
sns.set_style('white')
sns.set_context('paper')
g = sns.factorplot(x="Ligand",y="KD",col='Analyte', data=df, kind='bar', col_wrap=5).set(yscale='log')
g.set_titles("{col_name}")
g.set_xticklabels(rotation=90,size=8)
ax = plt.gca()
ax.set_ylim([0.001,0.00000000001])

I want to flip y-axis that goes from top to bottom, 10^-3 to 10^-11 but I want to keep the columns going down. Such that the biggest column will be the lowest value. For example a 10^-11 will have the biggest column

回答1:

I found out that you can simply do:

plt.ylim(reversed(plt.ylim()))