Answer the question
In order to leave comments, you need to log in
How to plot in Python (Matplotlib) without blocking the console?
Yesterday I started working in the Python, Matplotlib libraries and a nuisance arose.
When plotting a chart, the console is completely blocked, it is impossible to enter anything until I close the window with the chart. After closing, the blocking disappears and you can write code again.
How can I create a chart without blocking the console?
My code:
import matplotlib.pyplot as plt
import numpy as np
t=np.arange(0.,5.,0.2)
plt.plot(t,t,'r--',t,t**2.'bs ',t,t**3,'g^'
Answer the question
In order to leave comments, you need to log in
plt.ion() + plt.draw() instead of plt.show()
There is also IPython Notebook that might be of interest. It has now been merged into a separate Jupyter project. You can try (Welcome to Python.ipynb -> Cell -> Run All) It will draw a graph for you right there, you can even paste your code and see what happens, just be careful, this is just a demo, all code is deleted later. And you can also deploy it on a local machine, if on Windows, then in general everything is simple: download anacondait includes a huge bunch of libraries (matplotlib, numpy, scipy...), run IPython (Py 3.4) Notebook, it is deployed on the local interface, on port 8888, everything, you can create your own sketches (*.ipynb), edit them directly in the browser, view graphs, save, and also fumble through Jupyter .
ps to display plots directly in the sketch, and not in a separate window, use the %matplotlib inline macro
How can I create a chart without blocking the console?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question