我的数据都是整数,但是画密度图以后,x轴居然有小数,有的图里y轴有小数。搜了半天也没找到好点的解决方案,终于在google找到了。
办法如下:
from matplotlib.ticker import MaxNLocator
加上下边这两句就OK了
plt.gca().xaxis.set_major_locator(MaxNLocator(integer=True))
plt.gca().yaxis.set_major_locator(MaxNLocator(integer=True))
搞定