【发布时间】:2013-08-28 19:12:18
【问题描述】:
使用上一个问题中的相同代码,此示例生成以下图表:
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
data = (0, 1890,865, 236, 6, 1, 2, 0 , 0, 0, 0 ,0 ,0 ,0, 0, 0)
ind = range(len(data))
width = 0.9 # the width of the bars: can also be len(x) sequence
p1 = plt.bar(ind, data, width)
plt.xlabel('Duration 2^x')
plt.ylabel('Count')
plt.title('DBFSwrite')
plt.axis([0, len(data), -1, max(data)])
ax = plt.gca()
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
ax.spines['left'].set_visible(False)
ax.spines['bottom'].set_visible(False)
plt.savefig('myfig')
而不是刻度标签是 0、2、4、6、8...我宁愿在每个标记处都标记它们,并继续使用 2^x 的值:1、2、4、8, 16 等。我该怎么做?然后更好的是,我可以让标签在栏下方居中,而不是在左边缘?
【问题讨论】:
标签: python matplotlib plot