0
我有以下条形图。使用matplotlib中的酒吧在轴顶部对齐xticks
我想上的曲线图的顶部上的x轴的xticks到与杆对准。
所以,与其间距[105, 20, 75, ...]
均匀,我想让他们分开,使得105是第一栏上方,4是最后一棒上面,等
这将如何做呢?
实施例代码(上图,其生成):
from matplotlib import pyplot as plt
x = [10, 20, 30, 40, 90]
y = [7, 8, 12, 25, 50]
other = [105, 20, 75, 20, 4]
fig,ax = plt.subplots()
plt.bar(x,y)
ax.set_title('title', y=1.04)
ax.set_xlabel('x label')
ax.set_ylabel('y label')
ax2 = ax.twiny()
ax2.set_xticklabels(ax2.xaxis.get_majorticklabels(), rotation=90)
ax2.set_xticklabels(other)
plt.show()