PYTHON PROGRAM – XIV
PYPLOT- IV
a) Given below are the sugar levels for men and women in a city. Compare the
sugar
levels among them through a histogram.
MEN=[113,85,90,150,149,88,93,115,135,80,77,82,129]
WOMEN=[67,98,89,120,133,150,84,69,89,79,120,112,100]
Ensure the following specifications in the chart
Title should be Blood Sugar Analysis
X axis label should be Sugar Range
Y axis label should be Total Number Of patients
Color for Men should be Red and for women should be black
Legends MEN and WOMEN should be placed in the upper left corner of your
chart
PROGRAM:
import [Link] as p
MEN=[113,85,90,150,149,88,93,115,135,80,77,82,129]
WOMEN=[67,98,89,120,133,150,84,69,89,79,120,112,100]
[Link]([MEN,WOMEN],bins=[60,80,100,120,140,160],color=['red','black'],label=['
MEN',
'WOMEN'])
[Link]("SUGAR RANGE")
[Link]("TOTAL NUMBER OF PATIENTS")
[Link]("BLOOD SUGAR ANALYSIS")
[Link](loc=1)
[Link]( )
OUTPUT:
b) Modify the above code to display the histogram horizontally and to display the
legend in the lower right corner.
PROGRAM
import [Link] as p
MEN=[113,85,90,150,149,88,93,115,135,80,77,82,129]
WOMEN=[67,98,89,120,133,150,84,69,89,79,120,112,100]
[Link]([MEN,WOMEN],bins=[60,80,100,120,140,160],color=['red','black'],label=['
ME
N','WOMEN'],orientation=’horizontal’)
[Link]("SUGAR RANGE")
[Link]("TOTAL NUMBER OF PATIENTS")
[Link]("BLOOD SUGAR ANLYSIS")
[Link](loc=4)
[Link]( )
OUTPUT: