In this video we’ll add a MatplotLib Graph to our Kivy App.

Adding matplotlib to a kivy app is pretty easy, we’ll use kivy_garden and it’ll be a piece of cake!

#kivy #codemy

Python Code:
GitHub Code:

from kivy.lang import Builder
from import MDApp
from kivy.uix.floatlayout import FloatLayout
from import FigureCanvasKivyAgg
import matplotlib.pyplot as plt

# Define what we want to graph
x = [1,2,3,4,5]
y = [5, 12, 6, 9, 15]

plt.ylabel("This is MY Y Axis")
plt.xlabel("X Axis")

class Matty(FloatLayout):
	def __init__(self, **kwargs):

		box =

	def save_it(self):
		name = self.ids.namer.text
		if name:

class MainApp(MDApp):
	def build(self):
		self.theme_cls.theme_style = "Dark"
		self.theme_cls.primary_palette = "BlueGray"
		return Matty()


Kivy Design Code: matty.kv
GitHub Code: matty.kv

		id: box
		size_hint_y: .8
		pos_hint: {"top":1}

		size_hint_y: .2
			id: namer
			multiline: False

			text: "Save It!!"
			on_release: root.save_it()

John Elder

John is the CEO of where he teaches over 100,000 students how to code! He founded one of the Internet's earliest advertising networks and sold it to a publicly company at the height of the first dot com boom. After that he developed the award-winning Submission-Spider search engine submission software that's been used by over 3 million individuals, businesses, and governments in over 42 countries. He's written several Amazon #1 best selling books on coding, and runs a popular Youtube coding channel.

View all posts


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

  • Hello John ! How are you ? Thanks, you helped me so much with your videos in kivy.
    I have a question : Can we use Matplotlib, drawnow, arduino and kivy together ?
    I was trying to read serial data from the arduino and plot it with kivy (real time plotting).
    I have been trying a lot of times but it didn’t work. Please could you help me ?

John Elder