জয়েন লগইন

ম্যাটপ্লটলিব

🌈ম্যাটপ্লটলিব কি?

📋ম্যাটপ্লটলিব হলো উন্নত অপারেশন সম্পাদন করার পদ্ধতি।

⚒️ম্যাটপ্লটলিব উন্নত অপারেশন সম্পাদন করতে ব্যবহৃত হয়।

ম্যাটপ্লটলিব সমূহ

ম্যাটপ্লটলিব এবং সেগুলোর ব্যবহারের তালিকা

  • ➡️ animation - অ্যানিমেশন তৈরি করা
  • ➡️ FuncAnimation - ফাংশনের মাধ্যমে অ্যানিমেশন তৈরি করা
  • ➡️ ArtistAnimation - একাধিক আর্টিস্টের মাধ্যমে অ্যানিমেশন তৈরি করা
  • ➡️ widgets - ইন্টারেক্টিভ উইজেট ব্যবহার করা
  • ➡️ Slider - স্লাইডার তৈরি করা
  • ➡️ Button - বোতাম তৈরি করা
  • ➡️ Cursor - কার্সার তৈরি করা
  • ➡️ events - ঘটনা পরিচালনা করা
  • ➡️ patches - আকার ও আকৃতির প্যাচ ব্যবহার করা
  • ➡️ collections - একাধিক গ্রাফিক উপাদানের সংগ্রহ তৈরি করা
  • ➡️ transforms - গ্রাফিক উপাদানের রূপান্তর নির্ধারণ করা
  • ➡️ 3D - ত্রিমাত্রিক গ্রাফ তৈরি করা
  • ➡️ projection - গ্রাফের প্রক্ষেপণ নির্ধারণ করা

animation - অ্যানিমেশন তৈরি করার উদাহরণ।

matplotlib
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation

figure, axes = plt.subplots()

line, = axes.plot([], [])

axes.set_xlim(0, 10)
axes.set_ylim(0, 10)

def update(frame):
    line.set_data(
        range(frame + 1),
        range(frame + 1)
    )

    return line,

animation = FuncAnimation(
    figure,
    update,
    frames=10
)

plt.show()

FuncAnimation - ফাংশনের মাধ্যমে অ্যানিমেশন তৈরি করার উদাহরণ।

matplotlib
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation

figure, axes = plt.subplots()

line, = axes.plot([], [])

def update(frame):
    line.set_data(
        [1, 2, 3, frame],
        [2, 4, 6, frame]
    )

    return line,

animation = FuncAnimation(
    figure,
    update,
    frames=10,
    interval=200
)

plt.show()

ArtistAnimation - একাধিক আর্টিস্টের মাধ্যমে অ্যানিমেশন তৈরি করার উদাহরণ।

matplotlib
import matplotlib.pyplot as plt
from matplotlib.animation import ArtistAnimation

figure, axes = plt.subplots()

artists = []

for number in range(1, 6):
    line, = axes.plot(
        [1, 2, 3],
        [number, number + 1, number + 2]
    )

    artists.append([line])

animation = ArtistAnimation(
    figure,
    artists,
    interval=500
)

plt.show()

widgets - ইন্টারেক্টিভ উইজেট ব্যবহার করার উদাহরণ।

matplotlib
import matplotlib.pyplot as plt
from matplotlib.widgets import Slider

figure, axes = plt.subplots()

x = [1, 2, 3, 4]
y = [2, 4, 6, 8]

line, = axes.plot(x, y)

slider_axes = figure.add_axes(
    [0.2, 0.05, 0.6, 0.03]
)

slider = Slider(
    slider_axes,
    "Scale",
    1,
    5,
    valinit=1
)

def update(value):
    line.set_ydata(
        [number * value for number in y]
    )

    figure.canvas.draw_idle()

slider.on_changed(update)

plt.show()

Slider - স্লাইডার তৈরি করার উদাহরণ।

matplotlib
import matplotlib.pyplot as plt
from matplotlib.widgets import Slider

figure, axes = plt.subplots()

x = [1, 2, 3, 4]
y = [2, 4, 6, 8]

line, = axes.plot(x, y)

slider_axes = figure.add_axes(
    [0.2, 0.05, 0.6, 0.03]
)

slider = Slider(
    slider_axes,
    "Value",
    1,
    10,
    valinit=1
)

def update(value):
    line.set_ydata(
        [number * value for number in y]
    )

    figure.canvas.draw_idle()

slider.on_changed(update)

plt.show()

Button - বোতাম তৈরি করার উদাহরণ।

matplotlib
import matplotlib.pyplot as plt
from matplotlib.widgets import Button

figure, axes = plt.subplots()

line, = axes.plot(
    [1, 2, 3],
    [2, 4, 6]
)

button_axes = figure.add_axes(
    [0.8, 0.05, 0.1, 0.05]
)

button = Button(
    button_axes,
    "Change"
)

def change(event):
    line.set_ydata(
        [6, 4, 2]
    )

    figure.canvas.draw_idle()

button.on_clicked(change)

plt.show()

Cursor - কার্সার তৈরি করার উদাহরণ।

matplotlib
import matplotlib.pyplot as plt
from matplotlib.widgets import Cursor

figure, axes = plt.subplots()

axes.plot(
    [1, 2, 3, 4],
    [2, 5, 3, 8]
)

cursor = Cursor(
    axes,
    useblit=True,
    color="red"
)

plt.show()

events - ঘটনা পরিচালনা করার উদাহরণ।

matplotlib
import matplotlib.pyplot as plt

figure, axes = plt.subplots()

def click(event):
    if event.inaxes:
        print(
            "x:",
            event.xdata,
            "y:",
            event.ydata
        )

connection = figure.canvas.mpl_connect(
    "button_press_event",
    click
)

axes.plot(
    [1, 2, 3, 4],
    [2, 5, 3, 8]
)

plt.show()

patches - আকার ও আকৃতির প্যাচ ব্যবহার করার উদাহরণ।

matplotlib
import matplotlib.pyplot as plt
from matplotlib.patches import Rectangle

figure, axes = plt.subplots()

rectangle = Rectangle(
    (1, 2),
    2,
    3
)

axes.add_patch(rectangle)

axes.set_xlim(0, 5)
axes.set_ylim(0, 6)

plt.show()

collections - একাধিক গ্রাফিক উপাদানের সংগ্রহ তৈরি করার উদাহরণ।

matplotlib
import matplotlib.pyplot as plt
from matplotlib.collections import LineCollection

figure, axes = plt.subplots()

segments = [
    [(1, 1), (2, 3)],
    [(2, 3), (3, 2)],
    [(3, 2), (4, 5)]
]

collection = LineCollection(
    segments
)

axes.add_collection(collection)

axes.set_xlim(0, 5)
axes.set_ylim(0, 6)

plt.show()

transforms - গ্রাফিক উপাদানের রূপান্তর নির্ধারণ করার উদাহরণ।

matplotlib
import matplotlib.pyplot as plt
import matplotlib.transforms as transforms

figure, axes = plt.subplots()

transform = transforms.Affine2D().rotate_deg(20)

axes.plot(
    [1, 2, 3],
    [2, 4, 3],
    transform=transform + axes.transData
)

plt.show()

3D - ত্রিমাত্রিক গ্রাফ তৈরি করার উদাহরণ।

matplotlib
import matplotlib.pyplot as plt

figure = plt.figure()

axes = figure.add_subplot(
    111,
    projection="3d"
)

x = [1, 2, 3, 4]
y = [2, 4, 3, 5]
z = [3, 5, 4, 7]

axes.plot(
    x,
    y,
    z
)

plt.show()

projection - গ্রাফের প্রক্ষেপণ নির্ধারণ করার উদাহরণ।

matplotlib
import matplotlib.pyplot as plt

figure = plt.figure()

axes = figure.add_subplot(
    111,
    projection="3d"
)

axes.scatter(
    [1, 2, 3],
    [2, 4, 3],
    [5, 6, 8]
)

plt.show()

ম্যাটপ্লটলিব সম্পর্কিত বিস্তারিত তথ্য

কার্যকর কোডিং উদাহরণ এবং সেগুলোর রেফারেন্স লিংক

নাম বিবরণ
animation অ্যানিমেশন তৈরি করতে ব্যবহৃত হয়।
FuncAnimation ফাংশনের মাধ্যমে অ্যানিমেশন তৈরি করতে ব্যবহৃত হয়।
ArtistAnimation একাধিক আর্টিস্টের মাধ্যমে অ্যানিমেশন তৈরি করতে ব্যবহৃত হয়।
widgets ইন্টারেক্টিভ উইজেট ব্যবহার করতে ব্যবহৃত হয়।
Slider স্লাইডার তৈরি করতে ব্যবহৃত হয়।
Button বোতাম তৈরি করতে ব্যবহৃত হয়।
Cursor কার্সার তৈরি করতে ব্যবহৃত হয়।
events ঘটনা পরিচালনা করতে ব্যবহৃত হয়।
patches আকার ও আকৃতির প্যাচ ব্যবহার করতে ব্যবহৃত হয়।
collections একাধিক গ্রাফিক উপাদানের সংগ্রহ তৈরি করতে ব্যবহৃত হয়।
transforms গ্রাফিক উপাদানের রূপান্তর নির্ধারণ করতে ব্যবহৃত হয়।
3D ত্রিমাত্রিক গ্রাফ তৈরি করতে ব্যবহৃত হয়।
projection গ্রাফের প্রক্ষেপণ নির্ধারণ করতে ব্যবহৃত হয়।