Interactive Graph Plotter Using Python, PictoBlox and Tobi
by vikasgovindrao in Teachers > 10
23 Views, 0 Favorites, 0 Comments
Interactive Graph Plotter Using Python, PictoBlox and Tobi
In this project, we will create an Interactive Graph Plotter using Python in PictoBlox.
The project allows the user to choose the type of graph they want to create and then enter their own data. The program uses Matplotlib to convert the data into a visual graph.
A Tobi sprite is also included to guide the user and provide messages during the process.
The project can create four different types of graphs:
- 📊 Bar Graph
- 📈 Line Graph
- 🥧 Pie Chart
- 🔵 Scatter Plot
This is a great project for learning Python, user input, loops, conditional statements, lists, functions and data visualization.
Supplies
You don't need any physical electronic components for this project.
Software
- PictoBlox
- Python Coding extension/environment
- Matplotlib library
- Tobi sprite
Create Tobi
Open PictoBlox and create a new Python project.
Add the Tobi sprite to your project.
We use Tobi to communicate with the user.
The basic command is:
We then create a function that allows Tobi to display messages:
Now we can use:
to make Tobi display a message.
Import Matplotlib
Matplotlib is a Python library used for creating graphs and visualizations.
Add:
The pyplot module provides functions for creating different types of charts.
For example:
creates a bar graph,
creates a line graph,
creates a pie chart, and
creates a scatter plot.
Take the User's Choice
The program asks the user which graph they want to create.
The program then checks the choice using conditional statements.
This allows the same program to create four different types of graphs.
Enter the Data
For each graph, the program asks the user to enter data.
For example, for a bar graph, the user can enter:
The category names are stored in one list:
and the numerical values are stored in another:
The program adds the data using:
Generate the Graph
After collecting the data, Matplotlib creates the selected graph.
Bar Graph
Line Graph
Pie Chart
Scatter Plot
The program also adds titles and axis labels to make the graphs easier to understand.
Test Your Project
Run the program in PictoBlox.
Try the following example:
Select:
for a Bar Graph.
Enter:
The program will automatically generate a bar graph showing the four values.
You can repeat the experiment with different data and different graph types
Project Link
https://drive.google.com/drive/folders/1ggM5srMvcFWTcI5RMcfIbLg6Zws07Q7x?usp=sharing