Categories
Python Answers

How to detach matplotlib plots so that the computation can continue with Python?

Spread the love

Sometimes, we want to detach matplotlib plots so that the computation can continue with Python.

In this article, we’ll look at how to detach matplotlib plots so that the computation can continue with Python.

How to detach matplotlib plots so that the computation can continue with Python?

To detach matplotlib plots so that the computation can continue with Python, we can call draw.

For instance, we write

from matplotlib.pyplot import plot, draw, show

plot([1,2,3])
draw()

# ...

show()

to call plot to plot a graph.

Then we call draw to draw it on screen and be allowed to continue running the rest of the script.

Finally, we call show at the end to show the final plot.

Conclusion

To detach matplotlib plots so that the computation can continue with Python, we can call draw.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *