I am trying to run a python file (test.py
) from command line in windows that contain a matplotlib plot. The file is running but the plot is only appearing for a fraction of second.
Here is the content of test.py
:
import matplotlib.pyplot as plt
plt.plot(range(10))
I am using the following command in cmd:
ipython test.py --matplotlib
The output is
Using matplotlib backend: Qt4Agg
The problem is the plot only appears for a fraction of second.
Enter the "python" command and your file's name. For example, if your Python file is named "script", you would type in python script.py here. If your Python file has one or more spaces in its name, you'll place quotation marks around the file name and extension (e.g., python "my script.py" ).
The best use of Matplotlib differs depending on how you are using it; roughly, the three applicable contexts are using Matplotlib in a script, in an IPython terminal, or in an IPython notebook.
Modify like this:
import matplotlib.pyplot as plt
plt.plot(range(10))
plt.show()
And run like this:
python test.py
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With