Matplotlib Tutorial
Edit Template
Edit Template
Matplotlib Tutorial
Edit Template

Matplotlib

What is Matplotlib

matplotlib का use हम data visualization के लिए करते हैं, यह एक python library है। इसके help से हम data को graph, chart or plot के form में देख सकते हैं। इसका use data analytics और scientific computation में अक्सर किया जाता है।

How to Install Matplotlib

ये python की library है इसलिए हमारे computer में पहले से python install होना जरूरी है, अब matplotlib को install करने के लिए हमें अपने computer में command terminal को open करना है और उसमें pip install matplotlib लिखकर enter press कर देना है अब कुछ ही time में matplotlib हमारे computer में install हो जाएगा।

Some Important Features of Matplotlib

Line Plots : matplotlib में line आसानी से draw किया जा सकता है। 

Histograms : इसका उसे data के distribution को visualize करने के लिए किया जाता है।

Bar Charts : अगर हम कई सारे categories को compare करना चाहते हैं तो bar chart का use करते हैं।

Scatter Plots : यह data points को dots के form में दिखता है।

Pie Charts : यह data को percentages में divide करके दिखाता है। 

Basic Example of Matplotlib

import matplotlib.pyplot as plt

# Data points
x = [1, 2, 3, 4, 5]
y = [2, 4, 6, 8, 10]

# Plot the graph
plt.plot(x, y)

# Labels aur Title add karte hain
plt.title("Simple Line Plot")
plt.xlabel("X-axis")
plt.ylabel("Y-axis")

# Graph ko dikhana
plt.show()

import : python library को अपने program मे use करने के लिए उसे अपने program मे import करना होता है, इसके लिए “import” use करते है। जैसा की इस example code के 1st line मे हमने matplotlib को import किया है import matplotlibl.pyplot as plt
यहाँ पर हमने “as” का use करके matplotlib को एक short form दिया है plt,इससे होता ये है की अब जहां भी हमे matplotlib लिखने की जरूरत होगी तो वह हम सिर्फ plt लिखेंगे हमारा काम हो जाएगा । आप plt के जगह कुछ भी ले सकते है but वो meaningful रहे, आम तौर पर हम plt का ही use करते है ।

Add a comment...

Your email address will not be published. Required fields are marked *

Scroll to Top