I am trying to set the axes for both x and y but every time I try it, the heatmap shrinks to a corner of the plot. I try
plt.xlim(0, 60)
plt.ylim(0, 30)
I've also tried:
ax.set_ylim(0, 30)
ax.set_xlim(0, 60)
But this does the same thing.
Here's what I have so far to call the heatmap:
pivot = df.pivot_table(index = 'Test X', columns = 'Test Y', values = 'Data')
ax = sns.heatmap(pivot, annot = True, fmt = .2g, cmap = 'Blues_r')
I want the X-axis to go from 0 - 60 and for it to show the range regardless of the data going to 60 or not and the same with y to 30. But this does not work.
By using
df = pd.DataFrame(np.random.random((15,15)))
sns.heatmap(df)
ax=plt.gca()
ax.set_xlim(0, 60)
I was able to get the figure with the required limits
Also, ax=sns.heatmap(df); ax.set_xlim(0, 60)
ax=sns.heatmap(df); ax.set_xlim(0, 60)
behave in the same way. Perhaps is the way you're calling ax.set_xlim
. Hope it helps
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.