In this Python Kivy article we want to learn about How to Create Scatter Chart with Python Kivy, Python Kivy is powerful framework for creating user interfaces in Python. it is open source and can be used for developing applications for desktops, mobile devices and web.
How to Create Scatter Chart with Python Kivy
First of all we need to install our required libraries
1 |
pip install kivy matplotlib |
Once we have installed required libraries, we need to import them in our Python code. we want to use Kivy for creating user interface and Matplotlib for creating the Scatter Chart.
1 2 3 4 5 |
import kivy from kivy.app import App from kivy.uix.boxlayout import BoxLayout from kivy.garden.matplotlib.backend_kivyagg import FigureCanvasKivyAgg import matplotlib.pyplot as plt |
After that we need to create the user interface using Kivy. we will create BoxLayout and added Matplotlib FigureCanvasKivyAgg widget to it.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
class ScatterChartApp(App): def build(self): # Create BoxLayout box_layout = BoxLayout(orientation='vertical') # Create Matplotlib FigureCanvasKivyAgg widget figure, ax = plt.subplots() canvas = FigureCanvasKivyAgg(figure) # Add Matplotlib widget to the BoxLayout box_layout.add_widget(canvas) return box_layout |
And finally we need to create Scatter Chart using Matplotlib. we want to use a simple example to create Scatter Chart that shows the relationship between height and weight for a group of people.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
class ScatterChartApp(App): def build(self): # Create BoxLayout box_layout = BoxLayout(orientation='vertical') # Create Matplotlib FigureCanvasKivyAgg widget figure, ax = plt.subplots() canvas = FigureCanvasKivyAgg(figure) # Add Matplotlib widget to the BoxLayout box_layout.add_widget(canvas) # Create Scatter Chart heights = [150, 155, 160, 165, 170, 175, 180, 185, 190] weights = [50, 55, 60, 65, 70, 75, 80, 85, 90] ax.scatter(heights, weights) return box_layout |
Now we can run our application by creating an instance of the ScatterChartApp class and calling its run method.
1 2 |
if __name__ == '__main__': ScatterChartApp().run() |
This is the complete code for this article
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
import kivy from kivy.app import App from kivy.uix.boxlayout import BoxLayout from kivy.garden.matplotlib.backend_kivyagg import FigureCanvasKivyAgg import matplotlib.pyplot as plt class ScatterChartApp(App): def build(self): # Create BoxLayout box_layout = BoxLayout(orientation='vertical') # Create Matplotlib FigureCanvasKivyAgg widget figure, ax = plt.subplots() canvas = FigureCanvasKivyAgg(figure) # Add Matplotlib widget to the BoxLayout box_layout.add_widget(canvas) # Create Scatter Chart heights = [150, 155, 160, 165, 170, 175, 180, 185, 190] weights = [50, 55, 60, 65, 70, 75, 80, 85, 90] ax.scatter(heights, weights) return box_layout if __name__ == '__main__': ScatterChartApp().run() |
When you run this code, it will creates a Scatter Chart that displays relationship between height and weight for a group of people. you can modify the data to create your own Scatter Chart with Kivy.
This will be the result

Learn More on Kivy
- Introduction to Python Kivy
- How to Integrate Yahoo Finance with Python Kivy
- How to Build Music Player with Kivy
- Build Android Application with Python Kivy
- How to Integrate Matplotlib with Python Kivy
- How to Integrate Pandas with Python Kivy
- Building Cross Platform GUI Applications with Python Kivy
- Getting Started with Kivy in Python
- How to Create Uis with Python and Kivy
- How to Create BarChart with Python Kivy
- How to Create LineChart with Python Kivy