ပုံတစ်ခုတည်းတွင် matplotlib ကွက်များစွာကို ဖန်တီးနည်း
ပုံတစ်ခုတည်းတွင် Matplotlib ကွက်များစွာကို ဖန်တီးရန် အောက်ပါ syntax ကို သင်အသုံးပြုနိုင်သည်-
import matplotlib. pyplot as plt #define grid of plots fig, axs = plt. subplots (nrows= 2 , ncols= 1 ) #add data to plots axs[0]. plot (variable1, variable2) axs[1]. plot (variable3, variable4)
အောက်ဖော်ပြပါ ဥပမာများသည် ဤလုပ်ဆောင်ချက်ကို လက်တွေ့အသုံးချနည်းကို ပြသထားသည်။
ဥပမာ 1- Stacking Paths ဒေါင်လိုက်
အောက်ဖော်ပြပါ ကုဒ်သည် ဒေါင်လိုက် အစီအမံဖြင့် Matplotlib ကွက်သုံးခုကို ဖန်တီးနည်းကို ပြသသည်-
#create some data
var1 = [1, 2, 3, 4, 5, 6]
var2 = [7, 13, 16, 18, 25, 19]
var3 = [29, 25, 20, 25, 20, 18]
#define grid of plots
fig, axs = plt. subplots (nrows= 3 , ncols= 1 )
#add title
fig. suptitle (' Plots Stacked Vertically ')
#add data to plots
axs[0]. plot (var1, var2)
axs[1]. plot (var1, var3)
axs[2]. plot (var2, var3)
ဥပမာ 2- လမ်းကြောင်းများကို အလျားလိုက် စီခြင်း
အောက်ဖော်ပြပါ ကုဒ်သည် Matplotlib ကွက် ၃ ခုကို အလျားလိုက် အထပ်လိုက် ပြုလုပ်နည်းကို ပြသသည်-
#create some data
var1 = [1, 2, 3, 4, 5, 6]
var2 = [7, 13, 16, 18, 25, 19]
var3 = [29, 25, 20, 25, 20, 18]
#define grid of plots
fig, axs = plt. subplots (nrows= 1 , ncols= 3 )
#add title
fig. suptitle (' Plots Stacked Horizontally ')
#add data to plots
axs[0]. plot (var1, var2)
axs[1]. plot (var1, var3)
axs[2]. plot (var2, var3)
ဥပမာ 3- ကွက်ကွက်ဇယားတစ်ခု ဖန်တီးပါ။
အောက်ပါကုဒ်သည် Matplotlib ကွက်ကွက်ဇယားကွက်ကို ဖန်တီးနည်းကို ပြသသည်-
#create some data
var1 = [1, 2, 3, 4, 5, 6]
var2 = [7, 13, 16, 18, 25, 19]
var3 = [29, 25, 20, 25, 20, 18]
var4 = [4, 4, 6, 4, 7, 11]
#define grid of plots
fig, axs = plt. subplots (nrows= 2 , ncols= 2 )
#add title
fig. suptitle (' Grid of Plots ')
#add data to plots
axs[0, 0]. plot (var1, var2)
axs[0, 1]. plot (var1, var3)
axs[1, 0]. plot (var1, var4)
axs[1, 1]. plot (var3, var1)
ဥပမာ 4- ပါဆယ်များကြား ပုဆိန်များ မျှဝေပါ။
ကွက်များစွာသည် တူညီသော x-axis ကိုအသုံးပြုကြောင်းသေချာစေရန် sharex နှင့် sharey အကြောင်းပြချက်များကို သင်အသုံးပြုနိုင်သည်-
#create some data
var1 = [1, 2, 3, 4, 5, 6]
var2 = [7, 13, 16, 18, 25, 19]
var3 = [29, 25, 20, 25, 20, 18]
var4 = [4, 4, 6, 4, 7, 11]
#define grid of plots
fig, axs = plt. subplots (nrows= 2 , ncols= 2 , sharex= True , sharey= True )
#add title
fig. suptitle (' Grid of Plots with Same Axes ')
#add data to plots
axs[0, 0]. plot (var1, var2)
axs[0, 1]. plot (var1, var3)
axs[1, 0]. plot (var1, var4)
axs[1, 1]. plot (var3, var1)
ထပ်လောင်းအရင်းအမြစ်များ
Matplotlib အပိုင်းခွဲများကြား အကွာအဝေးကို ချိန်ညှိနည်း
Matplotlib တွင် နောက်ခံအရောင်ပြောင်းနည်း
Matplotlib တွင် ကွက်ကွက်အရွယ်အစားကို မည်သို့တိုးမည်နည်း။