Important Programs Plotting with Python Class 12

In this article, you will find Important Programs Plotting with Python Class 12. You can use these programs in your practical file as practical records.

Important Programs Plotting with Python Class 12

In this section of important programs plotting with python class 12, we will cover practicals to plot a single line chart.

[1] Plot following data on line chart:

DayMondayTuesdayWednesdayThursdayFriday
Income510350475580600
  1. Write a title for the chart “The Weekly Income Report”.
  2. Write the appropriate titles of both the axes.
  3. Write code to Display legends.
  4. Display red color for the line.
  5. Use the line style – dashed
  6. Display diamond style markers on data points
import matplotlib.pyplot as pp
day =['Monday','Tuesday','Wednesday','Thursday','Friday']
inc = [510,350,475,580,600]
pp.plot(day,inc,label='Income',color='r',linestyle='dashed',marker='D')
pp.title("The Weekly Income Report")
pp.xlabel("Days")
pp.ylabel("Income")
pp.legend()
pp.show()

[2] A Shivalik restaurant has recorded the following data into their register for their income by Drinks and Food. Plot them on the line chart.

DayMondayTuesdayWednesdayThursdayFriday
Drinks450560400605580
Food490600425610625

Apply following customization to the line chart.

  1. Write a title for the chart “The Weekly Restaurant Orders”.
  2. Write the appropriate titles of both the axes.
  3. Write code to Display legends.
  4. Display your choice of colors for both the lines drinks and food.
  5. Use the line style – dotted for drinks and dashdot for food.
  6. Display plus markers on drinks and x markers of food.
import matplotlib.pyplot as pp
day =['Monday','Tuesday','Wednesday','Thursday','Friday']
dr = [450,560,400,605,580]
fd = [490,600,425,610,625]
pp.plot(day,dr,label='Drinks',color='g',linestyle='dotted',marker='+')
pp.plot(day,fd,label='Food',color='m',linestyle='dashdot',marker='x')
pp.title("The Weekly Restaurant Orders")
pp.xlabel("Days")
pp.ylabel("Orders")
pp.legend()
pp.show()

[3] Observe the given data for monthly views of one of the youtube channels for 6 months. Plot them on the line chart.

MonthJanuaryFebruaryMarchAprilMayJune
Views250021001700350030003800

Apply following customizations to the chart:

  1. Give the title for the chart – “Youtube Stats”
  2. Use the “Month” label for X-Axis and “Views” for Y-Axis.
  3. Display legends.
  4. Use dashed lines with the width 5 point.
  5. Use red color for the line.
  6. Use dot marker with blue edge color and black fill color.
import matplotlib.pyplot as pp
mon =['January','February','March','April','May','June']
views = [2500,2100,1700,3500,3000,3800]
pp.plot(mon,views,label='Views State',color='r',linestyle='dashed', linewidth=4,\
        marker='o', markerfacecolor='k', markeredgecolor='b')
pp.title("Youtube Stats")
pp.xlabel("Months")
pp.ylabel("Views")
pp.legend()
pp.show()

[4] Consider the following data of a medical store and plot the data on the line chart:

MonthMasksSanitizerHand wash
March150044006500
April350045005000
May650055005800
June670060006300
July600056006200
August680063004500

Customize the chart as you wish.

import matplotlib.pyplot as pp
mon =['March','April','May','June','July','August']
mask= [1500,3500,6500,6700,6000,6800]
san = [4400,4500,5500,6000,5600,6300]
hw = [6500,5000,5800,6300,6200,4500]
pp.plot(mon,mask,label='Mask',color='g',linestyle='dashed', linewidth=4,\
        marker='o', markerfacecolor='k', markeredgecolor='r')
pp.plot(mon,san,label='Mask',color='b',linestyle='dashed', linewidth=4,\
        marker='3', markerfacecolor='k', markeredgecolor='g')
pp.plot(mon,hw,label='Mask',color='r',linestyle='dashed', linewidth=4,\
        marker='v', markerfacecolor='k', markeredgecolor='b')
pp.title("Fitwell Medical Store")
pp.xlabel("Months")
pp.ylabel("Covid Protections")
pp.legend()
pp.show()

[5] Use above data and subplot sanitizer data and handwash data.

import matplotlib.pyplot as pp
mon =['March','April','May','June','July','August']

san = [4400,4500,5500,6000,5600,6300]
hw = [6500,5000,5800,6300,6200,4500]

pp.subplot(2,1,1)
pp.plot(mon,san,label='Sanitizer',color='b',linestyle='dashed', linewidth=4,\
        marker='o', markerfacecolor='k', markeredgecolor='r')
pp.title("Fitwell Medical Store")

pp.legend()

pp.subplot(2,1,2)
pp.plot(mon,hw,label='Handwash',color='r',linestyle='dashed', linewidth=4,\
        marker='v', markerfacecolor='k', markeredgecolor='b')
pp.xlabel("Months")
pp.ylabel("Covid Protections")
pp.legend()
pp.show()

[6] Write a program to plot a range from 1 to 30 with step value 4. Use following algebraic expression to show data.

y = 5*x+2

import matplotlib.pyplot as pp
import numpy as np
x = np.arange(1,30,4)
y = 5 * x + 2
pp.plot(x,y)
pp.show()

[7] Display following bowling figures through bar chart:

OversRuns
16
218
310
45
import matplotlib.pyplot as pp
overs =[1,2,3,4]
runs=[6,18,10,5]
pp.bar(overs,runs,color='m')
pp.xlabel('Overs')
pp.xlabel('Runs')
pp.title('Bowling Spell Analysis')
pp.show()

[8] Observe following data and plot data according to given instructions:

Batsman2017201820192020
Virat Kohli2501185522031223
Steve Smith2340225020031153
Babar Azam1750214718961008
Rohit Sharma1463198518541638
Kane Williamson1256178518741974
Jos Butler1125185317691436
  1. Create a bar chart to display data of Virat Kohli & Rohit Sharma.
    • Customize the chart in this manner
      • Use different widths
      • Use different colors to represent different years score
      • Display appropriate titles for axis and chart
      • Show legends
  2. Create a bar chart to display data of Steve Smith, Kane Williamson & Jos Butler. Customize Chart as per your wish.
  3. Display data of all players for the specific year.

2 thoughts on “Important Programs Plotting with Python Class 12”

  1. waseem

    answer for 8th question?

Comment Your Views

%d bloggers like this: