尽管有价值(伪对数),Barplot python在相同的范围内yticks

时间:2017-12-01 10:06:04

标签: python matplotlib bar-chart yaxis

我试图在一个条形图中操纵我的y轴。说我有这个代码

import numpy as np
import matplotlib.pyplot as plt
N = 11
men_means = (-500,0,1,2,5,10,20,50,100,200,500)
men_std = (-500,0,1,2,5,10,20,50,100,200,500)

ind = np.arange(N)  # the x locations for the groups
width = 0.25       # the width of the bars

fig, ax = plt.subplots()
rects1 = ax.bar(ind, men_means, width, color='r', yerr=men_std)

women_means = (-500,0,1,2,5,10,20,50,100,200,500)
women_std = (-500,0,1,2,5,10,20,50,100,200,500)
rects2 = ax.bar(ind + width, women_means, width, color='y', yerr=women_std)

ax.set_ylabel('Scores')
ax.set_title('Scores by group and gender')
ax.set_xticks(ind + width)
ax.set_xticklabels(('G1', 'G2', 'G3', 'G4', 'G5', 'G6', 'G7'))

ax.legend((rects1[0], rects2[0]), ('Men', 'Women'))

plt.show()

它会给我一个线性的y轴。当然我可以使用' symlog'使y轴对数(对于我的原始数据也有负值),但我真正想要的是具有伪对数y轴',其中刻度设置为-500, - 200,-100,-50,[...],0,1,2,5,10,20,[...],500,但沿y轴平均分布。

有人可以帮忙吗? : - )

0 个答案:

没有答案