简体   繁体   中英

Seaborn heatmap, lines not of the same width

I'm plotting an heatmap with Seaborn. If I set lines that divide each cell with "linewidth=value", the lines are printed, but their width is not the same. (eg in my plot below the external vertical lines are thinner than the internal ones and the horizontal line between 1 and 2 is thicker than the other two).

Here's a simple code that recreates the issue:

import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns;sns.set()

plt.figure(figsize=(10,5)) 
df = np.random.rand(4,6)
ax = sns.heatmap(df,cmap="Blues",linewidths=1,linecolor='k')
plt.show()

And here's the heatmap that I get:

Why are the lines of different width when linewidths is 1 for all of them?

Let's ignore the fact that the first and last row of cells are smaller than the others, I know that that's an issue with the matplotlib version.

I was having the same problem. Passing rasterized=False as parameter to sns.heatmap() fixed it for me.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM