python-drawnow icon indicating copy to clipboard operation
python-drawnow copied to clipboard

Fix limitation of clearing one plot when another one gets focus

Open jonasstoetzel opened this issue 7 years ago • 3 comments

Hi stsievert, what is the cause of this limitation? I very much would like to use that feature. Are there any ways to circumvent the issue? Multiple instances of python did not work.

jonasstoetzel avatar Feb 08 '18 11:02 jonasstoetzel

Can you detail how to reproduce?

During development, I assumed only one figure would update at a time. It was assumed that subplots would be used if multiple images needed to updated at once.

stsievert avatar Feb 08 '18 17:02 stsievert

Yes, I try to do it. Do you want code or a detailed setup? setup: Define two functions make_fig_a and make_fig_b (subplot already included). Also retrieve data from serial port and then call drawnow twice.

def make_fig_a(data):
    subplot(1,2,1)
    for item in list(data):
        plt.plot(data[item], label=item)


def make_fig_a(data):
    subplot(1,2,2)
    for item in list(data):
        plt.plot(data[item], label=item)


if __name__ == '__main__':
    data1 = {'temp1' : []}
    data2 = {'temp2' : []}        
    while True:
        data1['temp1].append(5)  
        data2['temp2].append(5) 
        drawnow(make_fig_a(data=data1))
        drawnow(make_fig_a(data=data1))

jonasstoetzel avatar Feb 15 '18 10:02 jonasstoetzel

Thanks for the example. It looks like you have a typo in the last lines. I’ll put this on my todo list. It looks like it’s something with plt.clf, plt.show and plt.draw_all. I have to make all of these figure specific.

stsievert avatar Feb 15 '18 14:02 stsievert