[go: up one dir, main page]

0% found this document useful (0 votes)
9 views4 pages

PGM - 9

The document provides Python programming instructions for creating multiple line charts using Matplotlib. It details how to plot three data ranges on a single chart with specific color, line width, and style requirements, as well as legends and axis labels. Additionally, it includes a program to compare the populations of India and Pakistan from 1960 to 2010, specifying the chart's appearance and labeling.

Uploaded by

shradhauis
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)
9 views4 pages

PGM - 9

The document provides Python programming instructions for creating multiple line charts using Matplotlib. It details how to plot three data ranges on a single chart with specific color, line width, and style requirements, as well as legends and axis labels. Additionally, it includes a program to compare the populations of India and Pakistan from 1960 to 2010, specifying the chart's appearance and labeling.

Uploaded by

shradhauis
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/ 4

PYTHON PROGRAM – IX

PYPLOT-I

a) Create multiple line charts on common plot where three data ranges are plotted on
same chart. The data ranges to be plotted are
Data = [[5., 25., 45., 20.,15. ], [ 8., 13., 29., 27.,18. ], [ 9., 29., 27., 39.,22.] ]

Ensure to have the following specifications on the chart

i) Line should be red in color with width of 3 and dashed dotted line style ii)
Line should be green in color with width of 4 and dashed dotted style iii)
Line should be black in color with width of 2 and dashed line style iv) The
legends should be LINE-I, LINE-II and LINE-III and it should be placed in the
upper left corner
v) X Axis label should be X VALUES [0,1,2,3,4] vi) Y Axis label
should be Y VALUES [DATA VALUES] vii) Title of your
chart should be MULTI RANGE LINE CHART PROGRAM

import numpy as np import

matplotlib.pyplot as plt

Data = [[5., 25., 45., 20.,15. ], [ 8., 13., 29., 27.,18. ], [ 9., 29., 27., 39.,22.] ]

X=np.arange(5) plt.plot(X,Data[0],

color='r',linewidth=3,linestyle='-.',label='LINE-I') plt.plot(X,Data[1],

color='g',linewidth=4,linestyle=':',label='LINE-II') plt.plot(X,Data[2],

color='k',linewidth=2,linestyle='--',label='LINE-III') plt.legend(loc=2)

plt.title("Multi Range Line Chart") plt.xlabel('X VALUES [0,1,2,3,4]')

plt.ylabel('Y VALUES [DATA VALUES]')

plt.show()

30
OUTPUT

b) Write a program to plot a line chart to depict a comparison of population in


millions between India and Pakistan from 1960 to 2010.

31
YEAR 1960 1970 1980 1990 2000 2010

INDIA 449.48 553.57 696.783 870.133 1000.4 1309.1

PAKISTAN 44.91 58.09 78.07 107.7 138.5 170.6

The line chart should have the following specifications


i) Line chart for India should be red and for Pakistan it should be
green. ii) Line Thickness for India should be 4 and for Pakistan should be
2 iii) Line style for India should be Solid and for pakistan should be
dashed dot iv) Legends INDIA and PAKISTAN should be placed in upper
left corner. v) X Axis Label should be YEAR vi) Y Axis Label should be
POPULTION IN MILLIONS
vii) Title of the chart should be POPULATION COMPARISON B/W INDIA AND
PAKISTAN
PROGRAM

import matplotlib.pyplot as plt


I=[449.48,553.57,696.783,870.133,1000.4,1309.1]
P=[44.91,58.09,78.07,107.7,138.5,170.6] YR=
[1960,1970,1980,1990,2000,2010]
plt.plot(YR,I,color='r',linewidth=4,linestyle='-',label='INDIA')
plt.plot(YR,P,
color='g',linewidth=2,linestyle='-.',label='PAKISTAN')
plt.legend(loc=2)
plt.title("POPULATION COMPARISON B/W INDIA AND PAKISTAN")
plt.xlabel('YEAR') plt.ylabel('POPULATION IN MILLIONS') plt.show()

32
OUTPUT

33

You might also like