Skip to content Skip to sidebar Skip to footer

Plot Dynamic Heatmap/ Color Map In While Loop Python

I am working on a code to plot a heat map using matplotlib library,the problem I am facing is , instead of my (same) plot being updated for every new set of data in the loop I am g

Solution 1:

Well, It will be my 2nd answer to my own question :P I figured it out!

Just move this line: fig, (ax, ax2) = plt.subplots(nrows=2, sharex=True)above while loop,so that you initialize one figure and ask this figure to be constant while the values in the plot keeps on changing.

Do addplt.cla() in the end , within the while loop so you clear up the plot from the old data else the new plot will be overwritten/plotted over old one's.

Post a Comment for "Plot Dynamic Heatmap/ Color Map In While Loop Python"