我试着用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将其绘制为空白,而不是将其保留为“white”/空白(如果使用厘米喷气式飞机彩色地图。在
我现在得到的是这个。在
我怎样才能让它用它的颜色图填充空白?谢谢。