Matplotlib ရှိ ဝင်ရိုးအညွှန်းတည်နေရာကို ချိန်ညှိနည်း


Matplotlib တွင် ဝင်ရိုးအညွှန်းရာထူးများကို ချိန်ညှိရန် အောက်ပါအခြေခံအထားအသိုကိုသုံးနိုင်သည်။

 #adjust y-axis label position
ax. yaxis . set_label_coords (-.1, .5)

#adjust x-axis label position 
ax. xaxis . set_label_coords (.5, -.1)

အောက်ဖော်ပြပါ ဥပမာများသည် ဤ syntax ကို လက်တွေ့တွင် မည်သို့အသုံးပြုရမည်ကို ပြသထားသည်။

ဥပမာ 1- X ဝင်ရိုးပေါ်ရှိ အညွှန်းအနေအထားကို ချိန်ညှိပါ။

အောက်ပါကုဒ်သည် Matplotlib တွင်ကွက်ကွက်ဖန်တီးနည်းကိုပြသပြီး x-axis ပေါ်ရှိ အညွှန်းတည်နေရာကို ချိန်ညှိပါ-

 import matplotlib. pyplot as plt

#define data
x = [1, 2, 3, 4, 5, 6]
y = [4, 5, 8, 14, 24, 19]

#create scatterplot
fig, ax = plt. subplots ()
ax. scatter (x,y)

#add axis labels
ax. set_ylabel (' Y-Axis Label ')
ax. set_xlabel (' X-Axis Label ')

#adjust position of x-axis label
ax. xaxis . set_label_coords (.9, -.1) 

ဝင်ရိုးညှိနှိုင်းစနစ်သည် ကွက်ကွက်၏ဘယ်ဘက်အောက်ထောင့်ကိုကိုယ်စားပြုရန် ( 0.5 ၊ 0.5) နှင့် ညာဘက်အပေါ်ထောင့်ကိုကိုယ်စားပြုရန် (0.5၊ 0.5) ကို အသုံးပြုသည်ကို သတိပြုပါ။

ဥပမာ 2- Y ဝင်ရိုးပေါ်ရှိ တံဆိပ်အနေအထားကို ချိန်ညှိပါ။

အောက်ပါကုဒ်သည် Matplotlib တွင်ကွက်ကွက်ဖန်တီးနည်းကိုပြသပြီး Y ဝင်ရိုးအညွှန်း၏တည်နေရာကိုသာ ချိန်ညှိပါ-

 import matplotlib. pyplot as plt

#define data
x = [1, 2, 3, 4, 5, 6]
y = [4, 5, 8, 14, 24, 19]

#create scatterplot
fig, ax = plt. subplots ()
ax. scatter (x,y)

#add axis labels
ax. set_ylabel (' Y-Axis Label ')
ax. set_xlabel (' X-Axis Label ')

#adjust position of x-axis label
ax. yaxis . set_label_coords (-.1, .1) 

ဥပမာ 3- axes နှစ်ခုလုံး၏ အညွှန်းရာထူးများကို ချိန်ညှိပါ။

အောက်ပါကုဒ်သည် Matplotlib တွင်ကွက်ကွက်ဖန်တီးနည်းကိုပြသပြီး axes နှစ်ခု၏ အညွှန်းနေရာများ၏တည်နေရာကို ချိန်ညှိသည်-

 import matplotlib. pyplot as plt

#define data
x = [1, 2, 3, 4, 5, 6]
y = [4, 5, 8, 14, 24, 19]

#create scatterplot
fig, ax = plt. subplots ()
ax. scatter (x,y)

#add axis labels
ax. set_ylabel (' Y-Axis Label ')
ax. set_xlabel (' X-Axis Label ')

#adjust position of both axis labels
ax. yaxis . set_label_coords (-.1, .1)
ax. xaxis . set_label_coords (.9, -.1)

ထပ်လောင်းအရင်းအမြစ်များ

အောက်ဖော်ပြပါ သင်ခန်းစာများသည် Matplotlib ရှိ အခြားဘုံလုပ်ဆောင်ချက်များကို မည်သို့လုပ်ဆောင်ရမည်ကို ရှင်းပြသည်-

Matplotlib တွင် ပုဆိန်များကို ဝှက်နည်း
Matplotlib ရှိ အမှတ်အသားတံဆိပ်များကို လှည့်နည်း
Matplotlib ရှိ tick အရေအတွက်ကို ဘယ်လိုပြောင်းမလဲ။

မှတ်ချက်တစ်ခုထည့်ပါ။

သင့် email လိပ်စာကို ဖော်ပြမည် မဟုတ်ပါ။ လိုအပ်သော ကွက်လပ်များကို * ဖြင့်မှတ်သားထားသည်