[PYTHON] How to display images continuously with matplotlib Note

This article has experienced "This article is more than a year old since it was last updated."

I want to display continuously generated images using matplotlib.animation. You can do this by creating a function that generates an image and ʻimshowas follows. The reason why I didplt.clf ()` on the way was that it seemed to get heavier with each step, so I tried to clear it every time.

import matplotlib.pyplot as plt
import matplotlib.animation as animation
import numpy as np

N = 50

fig, ax = plt.subplots()

def update(i):
  a = np.uint8(np.random.uniform(0, 255, [N, N, 3]))
  a[i:, i:] = 0.
  plt.clf()
  plt.imshow(a)
hoge = animation.FuncAnimation(fig, update, np.arange(1,  N), interval=25)  #Will be erased if not assigned
plt.show()

that's all.

Recommended Posts

How to display images continuously with matplotlib Note
I want to display multiple images with matplotlib.
How to title multiple figures with matplotlib
How to suppress display error in matplotlib
How to display python Japanese with lolipop
[Python] How to draw multiple graphs with Matplotlib
Understand how to display images on Jupyter (utilization of imshow / matplotlib of OpenCV)
(Mac) How to display Japanese with Matplotlib and Seaborn At MacOS Sierra
How to use Matplotlib
How to avoid BrokenPipeError with PyTorch's DataLoader Note
How to turn off the scale value display while leaving the grid with matplotlib
Images created with matplotlib shift from dvi to pdf
How to process camera images with Teams or Zoom
[Python] How to draw a line graph with Matplotlib
[Python] How to create a 2D histogram with Matplotlib
[Python] How to draw a scatter plot with Matplotlib
[Note] How to use virtualenv
How to cast with Theano
How to Alter with SQLAlchemy?
How to separate strings with','
How to RDP with Fedora31
How to Delete with SQLAlchemy?
How to not load images when using PhantomJS with Selenium
[Ev3dev] How to display bmp image on LCD with python
How to display a list of installable versions with pyenv
For those who want to display images side by side as soon as possible with Python's matplotlib
How to plot a lot of legends by changing the color of the graph continuously with matplotlib
How to cancel RT with tweepy
Python: How to use async with
[Rails] How to display Google Map
Inference & result display with Tensorflow + matplotlib
How to collect images in Python
How to use virtualenv with PowerShell
How to deal with imbalanced data
How to install python-pip with ubuntu20.04LTS
How to deal with imbalanced data
How to get started with Scrapy
How to get started with Python
How to deal with DistributionNotFound errors
How to get started with Django
How to Data Augmentation with PyTorch
How to use FTP with Python
How to calculate date with python
How to install mysql-connector with pip3
Easy to draw graphs with matplotlib
Continuously color with matplotlib scatter plot
How to INNER JOIN with SQLAlchemy
How to install Anaconda with pyenv
How to authenticate with Django Part 2
How to authenticate with Django Part 3
[Memo] How to use BeautifulSoup4 (2) Display the article headline with Requests
[Note] How to change DocumentRoot after SSL conversion with Let's Encrypt
Two ways to display multiple graphs in one image with matplotlib
[Memo] How to use BeautifulSoup4 (3) Display the article headline with class_
How to display legend marks in one with Python 2D plot
How to do arithmetic with Django template
How to display the progress bar (tqdm)
How to process camera images with Teams and Zoom Sentiment analysis with Tensorflow
[Blender] How to set shape_key with script
[Python] How to specify the window display position and size of matplotlib
[Small story] How to save matplotlib graphs in a batch with Jupyter