How to plot Bitcoin Prices in real time (part 2) — Live animation plot with Python and Matplotlib

Опубликовано: 19 Август 2026
на канале: Andrew Fung
3,193
85

Hello Everyone! My name is Andrew Fung, in this video, we will be using the Python Matplotlib and Cryptocompare API to plot Bitcoin and other cryptocurrency prices in real time to take a look at the short term price fluctuation. For the second part of the video, I will be focusing on live plotting using an animation function inside Matplotlib.

#python #bitcoin #cryptocurrency #liveplotting #dataVisualization

Installation and Setup!
Cryptocompare library: https://pypi.org/project/cryptocompare/
Installing Jupyter Notebook: https://jupyter.readthedocs.io/en/lat...

Check out my Github!
https://github.com/Andrew-FungKinHo

How I make my YouTube videos:
⌨️ Keyboard - Nuphy Air75 Mechanical Keyboard - https://amzn.to/3Xu4PD3
🎙 Microphone - MAONO A04 Professional Podcaster USB Microphone - https://amzn.to/3k8ocD5
🖱 Mouse - Microsoft Bluetooth Ergonomic Mouse - https://amzn.to/3CHhdHJ
🔌 Accessories - Laptop Docking Station for MacBook Pro - https://amzn.to/3CHi5Mv

Timestamps
0:00 | Introduction
0:34 | Live animation plotting
11:36 | Side-by-Side comparison
12:27 | Out tro

Full code:
———————————————————————————————
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
import cryptocompare
from datetime import datetime

plt.style.use('seaborn')

x_vals = []
y_vals = []

def get_crypto_price(cryptocurrency,currency):
return cryptocompare.get_price(cryptocurrency,curr=currency)[cryptocurrency][currency]

def get_crypto_name(cryptocurrency):
return cryptocompare.get_coin_list()[cryptocurrency]['FullName']

def animate(i):
x_vals.append(datetime.now())
y_vals.append(get_crypto_price('BTC','USD'))

plt.cla()
plt.title(get_crypto_name('BTC') + ' Price Live Plotting')
plt.gcf().canvas.set_window_title('Live Plotting Cryptocurrency')

plt.xlabel('Date')
plt.ylabel('Price($)')
plt.plot_date(x_vals,y_vals,linestyle="solid",ms=0)
plt.tight_layout()


ani = FuncAnimation(plt.gcf(), animate, interval=1000)

plt.show()

———————————————————————————————

Feel free to drop a like and comment if you enjoy and video and let me know if you want me to do other types of programming videos ;) !!!