3

私のコードのこの部分は、図 (1) の棒グラフを生成します。より読みやすい図 (2) の棒グラフを作成するには、どのように変更すればよいのでしょうか。

axs[4].set_xticks(range(N))
axs[4].set_xticklabels(words[inds],rotation = 'vertical')
axs[4].set_xlabel('word')
axs[4].set_yscale('log')
axs[4].set_ylabel('pagerank')
axs[4].set_title('Sorted PageRank biased by total word frequencies (c = '+str(c4)+')')
axs[4].bar(range(N),p4[inds],lw=2.5, align='center')

plt.subplots_adjust(hspace=.5)

plt.savefig('./figures/pageranks.pdf')
4

2 に答える 2

2

pylab.bar の代わりに使用pylab.stepすると、必要なものに少し近いものが得られます。と同じ引数を取りますがbars、「バー」ではなく「ステップ」をプロットします。

import pylab as p
ax = p.gca()
xbins = p.linspace(0.,10.,10)
step_heights = [10, 9, 9, 9, 7, 6, 6, 5, 4, 3]
ax.step(xbins, step_heights, linewidth=2.5, color="k",where="mid")
ax.set_ylim(0.,11.)

ステッププロット

もう少し完全なpylab.histドキュメントを参照することもできます。

于 2013-09-08T09:02:43.127 に答える