Academic world

How to Make a Real time Plot or Figure in Python

Hello my friends and welcome!

In this video, I’m going to show you a simple code to make a real time plot or figure in Python.

It is very easy and quick to customize this python code to show what you want. Let’s see.

Python code

import time
import matplotlib.pyplot as plt
import random

fig = plt.figure()
ax = fig.add_subplot()
fig.show()
x = []
n = 150 # number of data points

for i in range(n):
    x.append(random.randint(0,100))
    ax.plot(x, color='r')
    fig.canvas.draw()
    ax.set_xlim(left=max(0, i - 50), right=i + 3)
    time.sleep(0.01)
plt.show()

P/s: If you find the post useful, share it to remember and to help other people as well.

Dr.Panda

Recent Posts

Adaptive Re-Start Hybrid Genetic Algorithm in Matlab

Hello everyone! In this post, I am going to show you my innovative version of…

2 weeks ago

Test Your Understanding About Genetic Algorithm (Test 2)

Hello everyone. Let’s take a test to check your understanding about genetic algorithm, with multiple…

4 weeks ago

Adaptive Restart Hybrid Genetic Algorithm

Hello everyone! In this post, I am going to show you my innovative version of…

1 month ago

Adaptive Re-Start Hybrid Genetic Algorithm (Test the Performance in Case Studies)

Hello everyone. In this post, I am going to show you my innovative version of…

8 months ago

Adaptive Re-Start Hybrid Genetic Algorithm in Matlab

Hello everyone! Let’s see how my innovative version of Genetic Algorithm, called Adaptive Re-start Hybrid…

8 months ago

Crypto Quiz (Test Your Knowledge About Cryptocurrency)

Hello everyone! Let’s take a short quiz, to test your knowledge about crypto-currency, or crypto.…

12 months ago