Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Showing the plot window more than once

import matplotlib
import pylab
x=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
y=[2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
plotting=pylab.plot(x,y)
pylab.show(plotting)

The code above (specifically the last line) would pop up the graph below:

The result when the code is run

If I close the graph window, and run the last line (>>>pylab.show(plotting)) again, the graph would not pop up again. Why is that so? The code above was run in Python 2.7.3.

like image 951
multigoodverse Avatar asked May 18 '26 09:05

multigoodverse


1 Answers

Because when you close the window python tears down and deletes the figure. Calling show again does nothing because there is no figure to show.

Passing an arguement to show like you do here does nothing (doc). The only argument that show takes is a key-word argument of block.

like image 125
tacaswell Avatar answered May 20 '26 00:05

tacaswell



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!