python - Why are the heatmap color values appearing as thin rectangular strips instead of squares? -
this question exact duplicate of:
how can improve appearance of heatmap? why color values appearing thin rectangular strips (with white space in between) instead of squares or happens depending on data file? not heatmap supposed like.
import numpy np import pandas pd import matplotlib.pyplot plt import seaborn sns sns.set(color_codes=true) np.random.seed(sum(map(ord, "distributions"))) data = pd.read_csv('dvang_heatmap.dat',sep='\s',engine='python') data2 = pd.pivot_table(data.round(2),values='k',index='g',columns='h') mask = np.isnan(data2) sns.set(style="white") xtics = 20 ytics = 10 cmap = "jet" vmin = none vmax = none ax = sns.heatmap(data2, xticklabels=xtics, yticklabels=ytics, mask=mask, linewidths=0, cbar=true, robust=false,cmap=cmap, vmin=vmin, vmax=vmax) ax.invert_yaxis() plt.title('heatmap') plt.xlabel('angle') plt.ylabel('separation') plt.savefig('heatmap.png', transparent=true) sns.plt.show()
read documentation. have add square=true keyword. default, option set false.
under hood, seaborn calling matplotlib.pyplot.imshow , using square keyword sets axes.set_aspect('equal'). if using square=true has extreme of effect, can try setting aspect manually: ax.set_aspect(num) num number describing height:width ratio of resulting rectangles.
