Assignment: Visualizing Basic Data
Objective:
Use Matplotlib to create different types of plots using Python. Learn to customize titles, axes
labels, and colors.
✅ Instructions:
You must complete all 6 tasks below. You can refer to W3Schools Matplotlib for help.
📌 Link: [Link]
Task 1: Line Plot – Student Marks
Plot the marks of a student in 5 subjects.
import [Link] as plt
subjects = ["Math", "Science", "English", "History", "Computer"]
marks = [85, 90, 78, 88, 95]
# Create a line plot here
What to do:
Add title: "Student Marks"
Label X-axis: "Subjects"
Label Y-axis: "Marks"
Change line color and style
Task 2: Bar Chart – Sales per Day
Show sales data of a store for 7 days using a bar chart.
days = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
sales = [150, 200, 180, 220, 300, 400, 250]
# Create a bar chart here
What to do:
Add title: "Weekly Sales"
Color bars: Use any color you like
Add axis labels
📝 Task 3: Pie Chart – Time Spent on Activities
Create a pie chart showing time spent in a day.
activities = ["Sleep", "Work", "Study", "Exercise", "Leisure"]
hours = [8, 6, 4, 2, 4]
# Create a pie chart here
What to do:
Add title: "Daily Time Distribution"
Add labels
Show percentages using autopct
Make one slice explode (e.g., “Sleep”)
Task 4: Multiple Lines in One Graph
Plot two students’ math scores in three terms.
terms = ["Term 1", "Term 2", "Term 3"]
student1 = [75, 85, 90]
student2 = [80, 78, 88]
# Plot both lines here
What to do:
Add legend for Student 1 and Student 2
Use different colors and markers
Add title and axis labels
Task 5: Customize Plot
Create any line plot and add the following customizations:
Line color: red
Line style: dotted
Marker: star
Grid: ON
Bonus Challenge (Optional):
Use a scatter plot to show random data:
import numpy as np
x = [Link](50)
y = [Link](50)