These exercises are designed to help you understand the key functionality of Matplotlib.
x = [1, 2, 3, 4, 5]
y = [2, 4, 3, 6, 5]- Create a simple line plot of
xvsy - Add a title and axis labels
- Plot the data using:
- a dashed line
- circular markers
- a green colour
height = [150, 155, 160, 165, 170, 175]
weight = [50, 55, 60, 65, 70, 75]- Create a scatter plot showing the relationship between height and weight.
- Label the axes clearly.
fruits = ["Apples", "Bananas", "Cherries", "Dates"]
sales = [50, 75, 40, 20]- Create a bar chart showing fruit sales.
- Add a title and rotate the x‑axis labels if needed.
countries = ["UK", "USA", "Germany", "France"]
population = [67, 331, 83, 65]- Create a horizontal bar chart.
- Add axis labels and a title.
scores = [55, 60, 62, 65, 70, 72, 75, 80, 85, 90]- Plot a histogram of the scores using 5 bins.
- Add a title and label the x‑axis.
months = ["Jan", "Feb", "Mar", "Apr"]
product_A = [30, 35, 40, 38]
product_B = [20, 22, 25, 30]- Plot both product lines on the same figure.
- Add a legend to distinguish them.