0

私はbroken_barhプロットを扱っています。単一の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()

1 つは 2 つのbroken_barh、もう 1 つは 3 つの 2 つのプロットを生成すると、次のようになります。

2broken_barh http://imageshack.us/a/img195/747/brokenbarhexample2.png

3 Broken_barh http://img341.imageshack.us/img341/5650/brokenbarhexamplenoyran.png

4

1 に答える 1

1

レンダリングは、利用可能なスペースにすべてを収めます。行を追加するにつれて図のサイズを大きくしたい場合は、次の方法で手動で行うことができます

 fig.set_size_inches(w, h * num_rows, forward=True)

固定バーの高さを強制します。

(ドキュメント)

于 2013-02-02T20:55:59.080 に答える