1

このような hexbin ダイアグラムを生成できます (コードはhttp://matplotlib.org/examples/pylab_examples/hexbin_demo.htmlから取得)

import numpy as np
import matplotlib.cm as cm
import  matplotlib.pyplot as plt

n = 100000
x = np.random.standard_normal(n)
y = 2.0 + 3.0 * x + 4.0 * np.random.standard_normal(n)
xmin = x.min()
xmax = x.max()
ymin = y.min()
ymax = y.max()

plt.subplots_adjust(hspace=0.5)
plt.subplot(121)
plt.hexbin(x,y, cmap=cm.jet)
plt.axis([xmin, xmax, ymin, ymax])
plt.title("Hexagon binning")
cb = plt.colorbar()
cb.set_label('counts')

plt.subplot(122)
plt.hexbin(x,y,bins='log', cmap=cm.jet)
plt.axis([xmin, xmax, ymin, ymax])
plt.title("With a log color scale")
cb = plt.colorbar()
cb.set_label('log10(N)')

plt.show()

hexbin の x 軸と y 軸に軸名を付ける方法はありますか? 「x-label」のようなものが x 軸の数字の下に表示され、「ylabel」が y 軸の数字の左側に表示されるようにします。これは、カラーバーのラベルに追加されます。

4

1 に答える 1

1

xlabelおよびylabelmatplotlib コマンドを使用できます。

plt.xlabel('x-label')
plt.ylabel('y-label')
于 2012-09-13T00:55:04.273 に答える