Siddharth Prajosh
Siddharth Prajosh

Reputation: 1384

Seaborn heatmap overlaps with previous data

I have a pandas df which I wanted to color code so I used seaborn heatmap to get it done. Works fine for most of the part. But when I create multiple plots, it overlaps with earlier ones.

SNS PLOT

p = sns.heatmap(df, annot=True, linewidths=0.3, cmap='RdYlGn').set_title(title)
pl = p.get_figure()
pl.tight_layout()
pl.set_size_inches(dim)
pl.savefig(img_name)

This happens when I run this code on multiple dfs or run it with the same df multiple times.

Upvotes: 0

Views: 2794

Answers (1)

Aziz
Aziz

Reputation: 102

Just clean the plot before every new plotting process.. Check the following answers:

[Stop seaborn plotting multiple figures on top of one another

When to use cla(), clf() or close() for clearing a plot in matplotlib?

Upvotes: 1

Related Questions