Matplotlib တွင် နောက်ခံအရောင်ပြောင်းနည်း (ဥပမာများနှင့်အတူ)


Matplotlib ရှိ ကွက်ကွက်တစ်ခု၏ နောက်ခံအရောင်ကို ပြောင်းလဲရန် အလွယ်ဆုံးနည်းလမ်းမှာ set_facecolor() အငြင်းအခုံကို အသုံးပြုခြင်းဖြစ်သည်။

Matplotlib တွင် ပုံတစ်ပုံနှင့် ဝင်ရိုးတစ်ခုကို အောက်ပါ syntax ကို အသုံးပြု၍ သတ်မှတ်ပါက၊

 fig, ax = plt. subplots ()

ထို့နောက် ကွက်ကွက်၏ နောက်ခံအရောင်ကို သတ်မှတ်ရန် အောက်ပါ syntax ကို ရိုးရိုးရှင်းရှင်း အသုံးပြုနိုင်ပါသည်။

 ax. set_facecolor (' pink ')

ဤသင်ခန်းစာသည် ဤလုပ်ဆောင်ချက်ကို လက်တွေ့အသုံးပြုခြင်း၏ ဥပမာများစွာကို ပေးပါသည်။

ဥပမာ 1- အရောင်အမည်ဖြင့် နောက်ခံအရောင် သတ်မှတ်ပါ။

အောက်ပါကုဒ်သည် အရောင်တစ်ခု၏အမည်ကို အသုံးပြု၍ Matplotlib ကွက်ကွက်တစ်ခု၏ နောက်ခံအရောင်ကို မည်သို့သတ်မှတ်ရမည်ကို ပြသသည်-

 import matplotlib. pyplot as plt

#define plot figure and axis
fig, ax = plt. subplots ()

#define two arrays for plotting
A = [3, 5, 5, 6, 7, 8]
B = [12, 14, 17, 20, 22, 27]

#create scatterplot and specify background color to be pink
ax. scatter (A, B)
ax. set_facecolor (' pink ')

#display scatterplot
plt. show () 

Matplotlib ရှိ နောက်ခံအရောင်

ဥပမာ 2- hexadecimal အရောင်ကုဒ်သုံးပြီး နောက်ခံအရောင် သတ်မှတ်ပါ။

အောက်ဖော်ပြပါကုဒ်သည် ဆယ်ဂဏန်းဂဏန်းရောင်ကုဒ်ကို အသုံးပြု၍ Matplotlib ကွက်ကွက်တစ်ခု၏ နောက်ခံအရောင်ကို မည်သို့သတ်မှတ်ရမည်ကို ပြသသည်-

 import matplotlib. pyplot as plt

#define plot figure and axis
fig, ax = plt. subplots ()

#define two arrays for plotting
A = [3, 5, 5, 6, 7, 8]
B = [12, 14, 17, 20, 22, 27]

#create scatterplot and specify background color to be pink
ax. scatter (A, B)
ax. set_facecolor (' #33FFA2 ')

#display scatterplot
plt. show () 

hex အရောင်ကုဒ်ကို အသုံးပြု၍ Matlplotlib နောက်ခံအရောင်

ဥပမာ 3- သီးခြားအပိုင်းခွဲတစ်ခုအတွက် နောက်ခံအရောင်ကို သတ်မှတ်ပါ။

တစ်ခါတစ်ရံတွင် သင့်တွင် Matplotlib မြေကွက်များစွာရှိသည်။ ဤကိစ္စတွင်၊ သင်သည် ကွက်ကွက်တစ်ခု၏ နောက်ခံအရောင်ကို သတ်မှတ်ရန် အောက်ပါကုဒ်ကို အသုံးပြုနိုင်သည်။

 import matplotlib. pyplot as plt

#define subplots
fig, ax = plt. subplots (2, 2)
fig. tight_layout ()

#define background color to use for each subplot
ax[0,0]. set_facecolor (' blue ')
ax[0,1]. set_facecolor (' pink ')
ax[1,0]. set_facecolor (' green ')
ax[1,1]. set_facecolor (' red ')

#display subplots
plt. show () 

မတူညီသောနောက်ခံများဖြင့် Matplotlib အပိုင်းခွဲများ

ဆက်စပ်- Matplotlib အပိုင်းခွဲများကြား အကွာအဝေးကို ချိန်ညှိနည်း

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

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