0% found this document useful (0 votes)
26 views

Some Insights of Matplotlib

The document discusses various types of plots that can be created using the Matplotlib library in Python, including pie charts, scatter plots, line plots, multiple line plots, and bar plots. Code examples are provided to demonstrate how to generate each type of plot using Matplotlib, with sample data and customizations like titles, labels, colors and markers. The plots allow visualization and comparison of data across different formats.

Uploaded by

ahmedliet143
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)
26 views

Some Insights of Matplotlib

The document discusses various types of plots that can be created using the Matplotlib library in Python, including pie charts, scatter plots, line plots, multiple line plots, and bar plots. Code examples are provided to demonstrate how to generate each type of plot using Matplotlib, with sample data and customizations like titles, labels, colors and markers. The plots allow visualization and comparison of data across different formats.

Uploaded by

ahmedliet143
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
You are on page 1/ 4

3/10/24, 10:00 PM Matplot Lib - Jupyter Notebook

MATPLOTLIB
Matplotlib is a low level graph plotting library in python that serves as
a visualization utilityin a variety of formats.
It is widely used for data visualization, plotting graphs, and creating
charts.

In [1]: import matplotlib.pyplot as plt


%matplotlib inline

Pie chart
In [2]: areas = ['Marketing', 'Sales', 'Development' , 'HR', 'Customer_support']
budget = [2.5,10,3,6,9]

In [21]: plt.pie(budget , labels = areas, autopct = "%0.1f%%")


plt.legend(title = 'Departments',loc= 'upper left', bbox_to_anchor=(1.2, 1)
plt.show()

Scatter Plot

localhost:8888/notebooks/Matplot Lib.ipynb# 1/4


3/10/24, 10:00 PM Matplot Lib - Jupyter Notebook

In [25]: x = [23,45,12,49,97,32,11,44]
y=[45,34,67,87,55,22,89,90]
plt.scatter(x,y)

plt.title("Age vs Salary")
plt.xlabel("Age")
plt.ylabel("Salary")


plt.show()

Line Plot
In [29]: product_id = [1,2,3,4,5,6,7,8]
online_price = [233,456,770,123,222,888,200,300]
offline_price = [400,300,100,333,444,565,600,899]
chor_bazar = [11,22,33,44,55,66,77,88]
plt.plot(product_id,online_price, color = 'Orange' , marker = '*')

Out[29]: [<matplotlib.lines.Line2D at 0x1d731d6df10>]

Multiple Line Plot

localhost:8888/notebooks/Matplot Lib.ipynb# 2/4


3/10/24, 10:00 PM Matplot Lib - Jupyter Notebook

In [30]: plt.plot(product_id,online_price, color = 'Orange' , marker = '*')


plt.plot(product_id,offline_price, color = 'Yellow' , marker = 'D')
plt.plot(product_id,chor_bazar, color = 'green' )

Out[30]: [<matplotlib.lines.Line2D at 0x1d7305059d0>]

Bar plot

localhost:8888/notebooks/Matplot Lib.ipynb# 3/4


3/10/24, 10:00 PM Matplot Lib - Jupyter Notebook

In [34]: product_id = [1, 2, 3, 4, 5, 6, 7, 8]


online_price = [233, 456, 770, 123, 222, 888, 200, 300]
offline_price = [400, 300, 100, 333, 444, 565, 600, 899]
chor_bazar = [11, 22, 33, 44, 55, 66, 77, 88]


plt.subplot(1, 3, 1)
plt.bar(product_id, online_price, color='blue')
plt.title('Online Price')

plt.subplot(1, 3, 2)
plt.bar(product_id, offline_price, color='green')
plt.title('Offline Price')

plt.subplot(1, 3, 3)
plt.bar(product_id, chor_bazar, color='orange')
plt.title('Chor Bazar Price')

plt.show()

localhost:8888/notebooks/Matplot Lib.ipynb# 4/4

You might also like