Matplotlib တွင် ဖောင့်များကို မည်သို့ပြောင်းနည်း (ဥပမာများဖြင့်)
Matplotlib တွင် ဖောင့်မိသားစုကို ပြောင်းလဲရန် အောက်ပါနည်းလမ်းများကို သင်အသုံးပြုနိုင်သည်-
နည်းလမ်း 1- စာသားအားလုံးအတွက် ဖောင့်ကို ပြောင်းပါ။
import matplotlib matplotlib. rcParams [' font.family '] = ' monospace '
နည်းလမ်း 2- ခေါင်းစဉ်နှင့် ဝင်ရိုးအညွှန်းများ၏ ဖောင့်ကို ပြောင်းပါ။
import matplotlib. pylot as plt mono_font = {' fontname ': ' monospace '} serif_font = {' fontname ': ' serif '} plt. title (' Title of Plot ', ** mono_font) plt. xlabel (' X Label ', ** serif_font)
အောက်ဖော်ပြပါ ဥပမာများသည် နည်းလမ်းတစ်ခုစီကို လက်တွေ့အသုံးချနည်းကို ပြသထားသည်။
နည်းလမ်း 1- စာသားအားလုံးအတွက် ဖောင့်ကို ပြောင်းပါ။
အောက်ပါကုဒ်သည် Matplotlib ကွက်ကွက်ရှိ စာသားအားလုံးအတွက် ဖောင့်မိသားစုကို မည်သို့ပြောင်းလဲရမည်ကို ပြသသည်-
import matplotlib
import matplotlib. pyplot as plt
#define font family to use for all text
matplotlib. rcParams [' font.family '] = ' monospace '
#define x and y
x = [1, 4, 10]
y = [5, 9, 27]
#create line plot
plt. plot (x, y)
#add title and axis labels
plt. title (' Title of Plot ')
plt. xlabel (' XLabel ')
plt. ylabel (' Y Label ')
#displayplot
plt. show ()
၎င်းသည် rcParams အငြင်းအခုံတွင် ကျွန်ုပ်တို့သတ်မှတ်ထားသော ဖောင့်မိသားစုဖြစ်သောကြောင့် axes နှစ်ခုလုံး၏ ခေါင်းစဉ်နှင့် အညွှန်းများတွင် “ monospace” ဖောင့်ရှိသည်ကို သတိပြုပါ။
နည်းလမ်း 2- ခေါင်းစဉ်နှင့် ဝင်ရိုးအညွှန်းများ၏ ဖောင့်ကို ပြောင်းပါ။
အောက်ပါကုဒ်သည် ခေါင်းစဉ်နှင့် ဝင်ရိုးအညွှန်းများအတွက် သီးသန့်ဖောင့်မိသားစုကို သတ်မှတ်နည်းကို ပြသသည်-
import matplotlib. pyplot as plt
#define font families to use
mono_font = {' fontname':'monospace '}
serif_font = {' fontname':'serif '}
#define x and y
x = [1, 4, 10]
y = [5, 9, 27]
#create plot of x and y
plt. plot (x, y)
#specify title and axis labels with custom font families
plt. title (' Title of Plot ', ** mono_font)
plt. xlabel (' X Label ', ** serif_font)
plt. ylabel (' Y Label ', ** serif_font)
#displayplot
plt. show ()
ခေါင်းစဉ်သည် “ monospace” ဖောင့်မိသားစုကို အသုံးပြုထားပြီး X နှင့် Y ဝင်ရိုးအညွှန်းများသည် “ Serif” ဖောင့်မိသားစုကို အသုံးပြုကြောင်း သတိပြုပါ။
မှတ်ချက် – Matplotlib တွင် သင်အသုံးပြုနိုင်သည့် ရရှိနိုင်သော ဖောင့်မိသားစုများ၏ စာရင်းအပြည့်အစုံကို ဤနေရာတွင် ရှာတွေ့နိုင်ပါသည်။
ထပ်လောင်းအရင်းအမြစ်များ
အောက်ဖော်ပြပါ သင်ခန်းစာများသည် Matplotlib ရှိ အခြားသော ဘုံလုပ်ဆောင်ချက်များကို မည်သို့လုပ်ဆောင်ရမည်ကို ရှင်းပြသည်-
Matplotlib ကွက်တွင် ဖောင့်အရွယ်အစားကို မည်သို့ပြောင်းလဲမည်နည်း။
Matplotlib တွင် ဒဏ္ဍာရီဖောင့်အရွယ်အစားကို မည်သို့ပြောင်းလဲမည်နည်း။
Matplotlib ရှိ checkmark အညွှန်းများ၏ ဖောင့်အရွယ်အစားကို သတ်မှတ်နည်း