0

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.

Siddharth Prajosh
  • 1,013
  • 2
  • 9
  • 16

1 Answers1

1

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?

Aziz
  • 102
  • 8