我需要用Python绘制一个条形图。我写了一个简单的示例代码。
import matplotlib.pyplot as plt
fig = plt.figure(figsize=(10, 8))
ax = fig.add_subplot(111)
x_axis = [20, 32, 64, 96, 160, 192, 224, 288, 320, 352, 416, 512, 576, 704, 864, 1024, 1056, 1152, 1408, 1536, 1824, 1952, 4096, 4192, 4896, 5664, 6144, 6176, 6944, 12128, 12288, 13824, 15424, 16384, 16768, 28800, 39520, 49152, 64512, 73728, 114688, 147456, 444544, 451200, 1206400, 1453472, 2565504, 3833856, 7243776, 17350656, 26007552, 42844160]
y_axis = [1, 31, 32, 63, 7, 11, 1, 2, 1, 1, 1, 4, 6, 26, 1, 1, 4, 2, 5, 1, 1, 1, 1, 4, 1, 1, 1, 48, 1, 1, 3, 1, 1, 4, 51, 1, 2, 4, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
ax.bar(x_axis, y_axis, align='center')
ax.set_xticks(x_axis)
ax.set_xticklabels([i for i in x_axis])
fig.savefig('graph.png')
但它生成的图形是完全错误的。这里怎么了。