4

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. (e.g. 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.

gprezza
  • 61
  • 4
  • @ImportanceOfBeingErnest I edited the question to explain better what I mean. I am not asking about the first and last row of cells being cut in half, rather about the lines dividing all the cells being of different width. – gprezza Oct 14 '19 at 12:53
  • That's a problem with pixel snapping I suppose. It should not occur on pdf output and also should be less pronounced the higher the dpi. – ImportanceOfBeingErnest Oct 14 '19 at 13:39

1 Answers1

1

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

mostueve
  • 21
  • 6