我正在尝试在条形图中操纵我的 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()
它会给我一个线性的轴。当然我可以使用'symlog'使y轴对数(对于我的原始数据也有负值)但我真正想要的是有一个'伪对数y轴',其中刻度设置为 - 500, -200, -100, -50, [..],0, 1, 2 ,5, 10, 20, [...], 500,但沿 y 轴均匀分布。
任何人都可以帮忙吗?:-)