পয়েন্ট সেটের কেন্দ্র বের করতে লিস্টের সকল এলিমেন্ট যোগ করে সেটির দৈর্ঘ্য দিয়ে ভাগ করলে সংশ্লিষ্ট অক্ষের কেন্দ্র ফলাফল হিসেবে পাওয়া যায়।
ধাপসমূহ
ডেটা পয়েন্টের দুটি লিস্ট তৈরি করুন।
plot() মেথড ব্যবহার করে x এবং y ডেটা পয়েন্ট প্লট করুন।
x এবং y ডেটা পয়েন্টের কেন্দ্র টাপল পান।
প্লটে কেন্দ্র বিন্দু রাখুন।
x এবং y ডেটা পয়েন্টের কেন্দ্র হিসেবে লেবেল অ্যানোটেট করুন।
ফিগার প্রদর্শন করতে show() মেথড ব্যবহার করুন।
উদাহরণ
from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True x = [5, 1, 3, 2, 8] y = [3, 6, 1, 0, 5] plt.plot(x, y) center = sum(x)/len(x), sum(y)/len(y) plt.plot(center[0], center[1], marker='o') plt.annotate( "center", xy=center, xytext=(-20, 20), textcoords='offset points', ha='right', va='bottom', bbox=dict(boxstyle='round,pad=0.5', fc='yellow', alpha=0.5), arrowprops=dict(arrowstyle='->', connectionstyle='arc3,rad=0')) plt.show()
আউটপুট
