0% found this document useful (0 votes)
4 views9 pages

DSP Unit - V

Uploaded by

hagavew644
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views9 pages

DSP Unit - V

Uploaded by

hagavew644
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

 Matplotlib is a data visualization library in Python.

The
pyplot, a sublibrary of Matplotlib, is a collection of
functions that helps in creating a variety of charts. Line
charts are used to represent the relation between two data
X and Y on a different axis. we will learn about line
charts and matplotlib simple line plots in Python.
ypoints=np.array([3,8,1,10])
plt.plot(x, y) # X=[2,3,4,5,6] and Y=[5,4,6,7,9]
plt.xlabel("X-axis") # add X-axis label
plt.ylabel("Y-axis") # add Y-axis label
plt.title("Any suitable title") # add title
plt.plot(ypoints,linestyle='dotted')
plt.plot(ypoints, linestyle = 'dashed')
plt.plot(ypoints, color = 'r')
plt.plot(ypoints, c = 'pink')
plt.plot(ypoints, linewidth = ‘8.9')
plt.show()
 Bar chart
 import matplotlib.pyplot as plt
import numpy as np
x = np.array(["A", "B", "C", "D"])
y = np.array([3, 8, 1, 10])
plt.bar(x,y)
 plt.barh(x, y)
 plt.bar(x, y, color = "red")
 plt.bar(x, y, width = 0.1)
 plt.barh(x, y, height = 0.1)
plt.show()
 A histogram is a graph showing frequency distributions.
 It is a graph showing the number of observations within

each given interval.


 The hist() function will read the array and
produce a histogram
 plt.hist(x)

Class
Frequ
Interva
ency
l

0-5 1

5-10 2

10-15 2

15-20 3

20-25 1

25-30 3
 import plotly.express as px
 fig = px.area(df, x='Year', y='Sales')
 fig.show()
 With Pyplot, you can use the pie() function to draw pie charts
 y = np.array([35, 25, 25, 15])
plt.pie(y)
plt.show()
 mylabels = ["Apples", "Bananas", "Cherries", "Dates"]
plt.pie(y, labels = mylabels)

 plt.pie(y, labels = mylabels, explode = myexplode)


 plt.pie(y, labels = mylabels, explode = myexplode,
shadow= True)
 mycolors = ["black", "hotpink", "b", "#4CAF50"]
plt.pie(y, labels = mylabels, colors = mycolors)

 plt.pie(y, labels = mylabels)


plt.legend(title = "Four Fruits:")
 Box Plot is a graphical method to visualize data distribution for gaining
insights and making informed decisions

Scatter Plots

import matplotlib.pyplot as plt


import numpy as np

x=
np.array([5,7,8,7,2,17,2,9,4,11,12,9,6])
y=
np.array([99,86,87,88,111,86,103,87,94,7
8,77,85,86])

plt.scatter(x, y)
plt.show()
colors =
np.array(["red","green","bl
ue","yellow","pink","black",
"orange","purple","beige","
brown","gray","cyan","mag
enta"])
 A Waffle Chart is a gripping visualization technique that is normally created to
display progress towards goals. Where each cell in the Waffle Chart constitutes
of 10 X 10 cell grid in which each cell represents one percentage point summing
up to total 100%.

# python program to generate Waffle Chart

# importing all necessary requirements


import pandas as pd
import matplotlib.pyplot as plt
from pywaffle import Waffle

# creation of a dataframe
data ={'phone': ['Xiaomi', 'Samsung',
'Apple', 'Nokia', 'Realme'],
'stock': [44, 12, 8, 5, 3]
}

df = pd.DataFrame(data)

# To plot the waffle Chart


fig = plt.figure(
FigureClass = Waffle,
rows = 5,
values = df.stock,
labels = list(df.phone)
 A Word Cloud is a picture made up of words where the size of each word
shows how frequently it appears in the dataset. They help us identify the most
common and important words in a text at a glance.

You might also like