KEMBAR78
Graph Plotting Questions Class12 | PDF | Chart | Histogram
0% found this document useful (0 votes)
45 views5 pages

Graph Plotting Questions Class12

The document outlines ten programs utilizing matplotlib and pandas for data visualization in various real-world scenarios. Each program includes specific tasks such as plotting line graphs, bar charts, and customizing visual elements like colors and labels. The objective is to effectively visualize data for different applications, including fitness tracking, sales reporting, and academic performance comparison.

Uploaded by

Aishi Dey
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views5 pages

Graph Plotting Questions Class12

The document outlines ten programs utilizing matplotlib and pandas for data visualization in various real-world scenarios. Each program includes specific tasks such as plotting line graphs, bar charts, and customizing visual elements like colors and labels. The objective is to effectively visualize data for different applications, including fitness tracking, sales reporting, and academic performance comparison.

Uploaded by

Aishi Dey
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Topic: Using matplotlib and pandas for effective data visualization

Objective: Plot various types of graphs with meaningful real-world scenarios.

Program 1 – Comparing Trainees’ Progress

Scenario: A fitness coach is tracking the daily performance of two trainees over 5 days.
The progress is measured in the number of sets completed.

x = [1, 2, 3, 4, 5]

y1 = [2, 4, 6, 8, 10] # Trainee A

y2 = [1, 3, 5, 7, 9] # Trainee B

1. Plot two line graphs (y1 and y2 vs x) using plt.subplot() in one figure.

2. Show the first graph in position (2,1,1) and the second in (2,1,2).

3. Add titles like "Trainee A" and "Trainee B" to each subplot.

4. Add grid to both graphs.

5. Save the figure as subplot_example.png.

Program 2 – Time vs Distance

Scenario: A self-driving car covers distance based on the square of time. The aim is to
visualize how fast the distance grows.

import numpy as np

x = np.arange(0, 10, 0.5)

y = x ** 2

1. Generate x values using np.arange() from 0 to 10 with step 0.5.

2. Plot a line graph for x vs y.

3. Label X-axis as "Time (hrs)" and Y-axis as "Distance (km)", and add a title.

4. Make the line dashed and blue.

5. Use square markers for all data points.


Program 3 – Monthly Sales Report

Scenario: A local shop tracks their monthly sales for the first five months of the year.
They want to see which month performed best.

import pandas as pd

data = pd.Series([150, 200, 180, 220, 210], index=['Jan', 'Feb', 'Mar', 'Apr', 'May'])

1. Plot a vertical bar chart using the Series.

2. Title the chart as "Monthly Sales (Series Bar Plot)".

3. Change the bar color to purple.

4. Label X-axis as "Month" and Y-axis as "Sales".

5. Save as series_bar.png.

Program 4 – Fruit Store Analytics

Scenario: A vendor wants to analyze the weekly sales of fruits to decide what to restock.

data = pd.Series([30, 25, 40], index=['Apples', 'Bananas', 'Oranges'])

1. Plot a horizontal bar chart using the above Series.

2. Change bar color to orange.

3. Label the axes appropriately.

4. Add grid lines along the X-axis.

5. Save the plot as fruits_horizontal.png.

Program 5 – Marks Comparison

Scenario: A teacher compares the scores of three students in Maths and Science to
evaluate their consistency across subjects.

data = {'Maths': [85, 80, 78], 'Science': [75, 88, 82]}

df = pd.DataFrame(data, index=['John', 'Sara', 'Ali'])

1. Plot a vertical bar chart from the DataFrame.

2. Use different colors for each subject.


3. Label X-axis as "Students" and Y-axis as "Marks".

4. Add the title "Marks Comparison – Subjects".

5. Save the plot as df_vertical.png.

Program 6 – Product Sales Tracking

Scenario: A company tracks sales of two products across three quarters. The marketing
team wants to visualize growth.

data = {'Product_A': [100, 150, 120], 'Product_B': [90, 130, 140]}

df = pd.DataFrame(data, index=['Q1', 'Q2', 'Q3'])

1. Plot a horizontal bar graph using the above DataFrame.

2. Use different colors for each product.

3. Add a legend.

4. Label X-axis as "Sales" and Y-axis as "Quarters".

5. Save the graph as sales_horizontal.png.

Program 7 – Survey Result Analysis

Scenario: A school survey categorizes responses into A, B, C, and D. The principal wants
to see which category received the most votes.

Categories = ['A', 'B', 'C', 'D']

Values = [20, 35, 30, 35]

1. Plot a vertical bar chart for the above data.

2. Set bar width to 0.3.

3. Use green as the bar color.

4. Label the axes appropriately.

5. Save the chart as custom_width.png.

Program 8 – Academic Year Comparison


Scenario: The school's performance in three subjects is compared between 2023 and
2024.

data = {'2023': [70, 80, 90], '2024': [75, 85, 95]}

df = pd.DataFrame(data, index=['Maths', 'Science', 'English'])

1. Plot a grouped bar chart for both years.

2. Add a legend for the years.

3. Label axes as "Subjects" and "Average Marks".

4. Rotate X-axis labels if needed.

5. Save as yearly_comparison.png.

Program 9 – Business Dashboard

Scenario: A business analyst prepares a dashboard showing overall company


performance using multiple chart types.

Data Assumptions:

 Line Graph: Monthly Sales

 Bar Chart: Product Sales

 Histogram: Marks Distribution

1. Create a 2x2 subplot layout.

2. Plot:

o Line Graph in (1,1)

o Bar Chart in (1,2)

o Histogram in (2,1)

3. Leave subplot (2,2) blank.

4. Add individual titles to each subplot.

5. Save the figure as multi_charts.png.


Program 10 – Stationery Sales Record

Scenario: A bookstore tracks weekly sales of various stationery items to restock


accordingly.

Items = ['Pen', 'Pencil', 'Notebook', 'Eraser']

Sales = [150, 200, 170, 100]

1. Plot a vertical bar chart using the data.

2. Customize tick marks on the X-axis.

3. Add grid lines only along the Y-axis.

4. Use sky blue for all bars.

5. Save the plot as stationery_sales.png.

You might also like