我正在尝试使用hexbin在方形轴上绘制一些数据。我使用以下内容:
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彩图。
我现在得到的是这个。
我怎样才能用它的颜色表填充空白空间? thanks.