0% found this document useful (0 votes)
6 views3 pages

Experiment No.3(Dv)

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)
6 views3 pages

Experiment No.3(Dv)

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/ 3

EXPERIMENT.NO.

3
Aim :Use A Data Visualization Library Such As Matplotlib Or Seaborn To
Create A Histogram And Plot The Histogram, Ensuring Appropriate Labelling
Of The X-Axis, Y-Axis, And Title To.

THEORY:
A histogram is an accurate representation of the distribution of numerical data. It is
an estimate of the probability distribution of a continuous variable. It is a kind of bar
graph.
To construct a histogram, follow these steps −

• Bin the range of values.


• Divide the entire range of values into a series of intervals.
• Count how many values fall into each interval.
The bins are usually specified as consecutive, non-overlapping intervals of a
variable.
The matplotlib.pyplot.hist() function plots a histogram. It computes and draws the
histogram of x.

Parameters
The following table lists down the parameters for a histogram −

x array or sequence of arrays

bins integer or sequence or ‘auto’, optional

optional parameters

range The lower and upper range of the bins.

density If True, the first element of the return tuple will be the counts normalized to form
a probability density

cumulative If True, then a histogram is computed where each bin gives the counts in that bin
plus all bins for smaller values.
histtype
The type of histogram to draw. Default is ‘bar’
• ‘bar’ is a traditional bar-type histogram. If multiple data are given the bars
are arranged side by side.
• ‘barstacked’ is a bar-type histogram where multiple data are stacked on

top of each other.


 ‘step’ generates a lineplot that is by default unfilled.
 ‘stepfilled’ generates a lineplot that is by default filled.

CODE.1: In this example, we will create a simple histogram using the hist() function with
the default parameters. The term ‘default parameters’ means that we will only pass the data as
the parameters to the hist() function in Matplotlib, all the other parameters will get a default
value.

O/P:

CODE 2:
Output:

RESULT: THE ABOVE PROGRAMS ARE SUCCESSFULLY EXECUTED AND NOW


LEARNED THE USE AND ABILITY TO APPLY MATPLOTLIB IN HISTOGRAM (BAR
CHART) PROGRAMMING.

You might also like