我正在使用broken_barh plots。有没有办法获得单个broken_barh的固定高度?图像应该在垂直方向上变大,但比例应该保持不变。
这里有一个简单的例子。
import matplotlib.pyplot as plt
import matplotlib as mlp
fig = plt.figure()
ax = fig.add_subplot(111)
broken_barh(self, xranges, yrange, **kwargs)
ax.broken_barh([(110, 30), (150, 10)], (0, 10), facecolors='blue')
ax.broken_barh([(10, 50), (100, 20), (130, 10)] , (10, 10),
facecolors=('red', 'yellow', 'green'))
ax.broken_barh([(50, 30), (85, 10)], (20, 10), facecolors='black')
ax.set_xlim(0,200)
ax.set_xlabel('seconds since start')
ax.set_yticks([0,10,20])
ax.set_yticklabels(['Bill', 'Jim', 'Jeff'])
ax.grid(True)
plt.savefig('broken_barh_example.png', bbox_inches='tight')
plt.show()如果我生成两个图,一个有两个broken_barh,另一个有三个,看起来像这样:
带2个broken_barh http://imageshack.us/a/img195/747/brokenbarhexample2.png
带3个broken_barh http://img341.imageshack.us/img341/5650/brokenbarhexamplenoyran.png
发布于 2013-02-03 04:55:59
渲染将所有内容都放入可用空间中。如果希望图形的大小随着添加的行数的增加而增加,可以通过
fig.set_size_inches(w, h * num_rows, forward=True)以强制设置固定的条形高度。
(doc)
https://stackoverflow.com/questions/14666326
复制相似问题