You are on page 1of 6

Name: Waqar Hussain Haideri

Reg. No.: 2018-MC-306


Subject: Probability and Statistics Lab
Submitted To: Engg. Saqib Zafar
Lab No. 03
Objective:
Introduction to Bar graph and Pie chart.
Theory:
Bar graph:
A bar graph can be defined as a chart or a graphical representation of data, quantities or numbers
using bars or strips. Bar graphs are used to compare and contrast numbers, frequencies or other
measures of distinct categories of data.
Histogram:

Histogram is similar as bar graph but a histogram group’s numbers into ranges .The height of
each bar shows how many fall into each range. And you decide what ranges to use!

Pie chart:

A Pie Chart is a type of graph that displays data in a circular graph. The pieces of the graph are
proportional to the fraction of the whole in each category. In other words, each slice of the pie is
relative to the size of that category in the group as a whole. The entire “pie” represents 100
percent of a whole, while the pie “slices” represent portions of the whole.
Tasks with MATLAB codes:
Bar graph:
Code:
syms x
a=[10 20 30 23 33 55]
b=[2001 2002 2003 2004 2006 2007]
x=bar(b,a)
title('Bar graph')
Results:

Fig.3.1: Bar graph


Histogram:
Code:
s= [ 37.5 34.2 47 45 46 45.5 31.2 55 54 48 32.5 33.7 47 ];
y=histogram(s);
xlabel('waiting time');
ylabel('people in firm');
Results:

Fig. 3.2: Histogram


Horizontal 3D bar graph:
Code:
c=[10 20 30 23 33 55]
d=[2001 2002 2003 2004 2006 2007]
z=bar3h(d,c,0.8,'stacke')
Results:
Fig. 3.2: Horizontal 3D bar graph
Horizontal bar graph:
Code:
e=[10 20 30 23 33 55]
f=[2001 2002 2003 2004 2006 2007]
w=barh(f,e,0.8,'stacke')
Results:

Fig. 3.3: Horizontal bar graph


Pie chart:
Code:
v= [ 37.5 34.2 47 45 46 45.6 55 4 ];
t=pie(v)
explode=[0 1 0 1 0 1 0 1]
pie (v,explode)
Results:

Fig. 3.4: Pie chart

You might also like