我正在嘗試使用hexbin來繪製方形軸上的一些數據。我用的是以下幾點:在matplotlib中製作六進制python在方形軸上填充空白空間?
import matplotlib.cm as cm
plt.figure()
num_pts = 1000
x = rand(num_pts) * 100
y = rand(num_pts) * 250
x_min = 0
x_max = 150
x_step = 25
y_min = 50
y_max = 300
y_step = 50
s = plt.subplot(1,1,1)
plt.hexbin(x,y,cmap=cm.jet,gridsize=20)
plt.xticks(range(x_min,x_max+x_step,x_step))
plt.yticks(range(y_min,y_max+y_step,y_step))
# square axes
s.axes.set_aspect(1/s.axes.get_data_ratio())
我想軸是正方形,我想設置我自己xticks/yticks和X-Y限制。對於某些軸的值,將不會有數據,所以hexbin計算出的計數應該爲零 - 我希望hexbin將其繪製爲空白空間,而不是在使用時將其保留爲「白色」/空白cm.jet彩圖。
我現在得到的是這個。
我怎樣才能使用它的顏色表填充空白空間?謝謝。3210
很有幫助。謝謝。 – Chuck
正是我在找什麼,謝謝! – irenemeanspeace