Matplotlib ဒဏ္ဍာရီတွင် ဒြပ်စင်များ၏ အစီအစဥ်ကို မည်သို့ပြောင်းလဲမည်နည်း။
Matplotlib ဒဏ္ဍာရီတွင် ဒြပ်စင်များ၏ အစီအစဥ်ကို ပြောင်းလဲရန် အောက်ပါကုဒ်အပိုင်းအစကို သင်အသုံးပြုနိုင်သည်-
#get handles and labels handles, labels = plt. gca (). get_legend_handles_labels () #specify order of items in legend order = [1,2,0] #add legend to plot plt. legend ([handles[idx] for idx in order],[labels[idx] for idx in order])
အောက်ဖော်ပြပါ ဥပမာသည် ဤ syntax ကို လက်တွေ့တွင် မည်သို့အသုံးပြုရမည်ကို ပြသထားသည်။
ဥပမာ- Matplotlib ဒဏ္ဍာရီရှိ အစိတ်အပိုင်းများ၏ အစီအစဥ်ကို ပြောင်းလဲပါ။
Matplotlib တွင် အောက်ဖော်ပြပါ စာကြောင်းဇယားကို ဖန်တီးသည်ဆိုပါစို့။
import pandas as pd import matplotlib. pyplot as plt #create data df = pd. DataFrame ({'points': [11, 17, 16, 18, 22, 25, 26, 24, 29], 'assists': [5, 7, 7, 9, 12, 9, 9, 4, 8], 'rebounds': [6, 8, 8, 10, 14, 12, 12, 10, 11]}) #add lines to plot plt. plot (df['points'], label='Points', color='green') plt. plot (df['assists'], label='Assists', color='steelblue') plt. plot (df['rebounds'], label='Rebounds', color='purple') #add legend plt. legend ()
ဒဏ္ဍာရီဒြပ်စင်များကို ကျွန်ုပ်တို့ဇာတ်ကွက်သို့ မျဉ်းကြောင်းများပေါင်းထည့်သည့်အစီအစဥ်အတိုင်း ထားရှိထားပါသည်။
သို့သော်၊ ဒဏ္ဍာရီပါဒဏ္ဍာရီရှိဒြပ်စင်များ၏အစီအစဥ်ကိုစိတ်ကြိုက်ပြင်ဆင်ရန်အောက်ပါအထားအသိုကိုသုံးနိုင်သည်။
import pandas as pd import matplotlib. pyplot as plt #create data df = pd. DataFrame ({'points': [11, 17, 16, 18, 22, 25, 26, 24, 29], 'assists': [5, 7, 7, 9, 12, 9, 9, 4, 8], 'rebounds': [6, 8, 8, 10, 14, 12, 12, 10, 11]}) #add lines to plot plt. plot (df['points'], label='Points', color='green') plt. plot (df['assists'], label='Assists', color='steelblue') plt. plot (df['rebounds'], label='Rebounds', color='purple') #get handles and labels handles, labels = plt. gca (). get_legend_handles_labels () #specify order of items in legend order = [1,2,0] #add legend to plot plt. legend ([handles[idx] for idx in order],[labels[idx] for idx in order])
ကျွန်ုပ်တို့သတ်မှတ်ထားသည်ကို သတိပြုပါ။
- အမှာစာ = [1၊ 2၊ 0]
ဆိုလိုသည်မှာ:
- ဒဏ္ဍာရီရှိ ပထမအရာသည် ဒဏ္ဍာရီဟောင်း (“ အကူအညီ” ) ၏ အညွှန်းကိန်းနေရာ 1 တွင် မူလအညွှန်းဖြစ်သင့်သည်။
- ဒဏ္ဍာရီ၏ ဒုတိယဒြပ်စင်သည် ဒဏ္ဍာရီဟောင်း၏ အညွှန်းကိန်းနေရာ 2 တွင် မူလအညွှန်းဖြစ်သင့်သည် (“ အပေါက်များ” )
- ဒဏ္ဍာရီ၏ တတိယဒြပ်စင်သည် ဒဏ္ဍာရီဟောင်း၏ အညွှန်းနေရာ 0 တွင် မူလတံဆိပ်ဖြစ်ရမည် (“ အမှတ်များ” )
ထပ်လောင်းအရင်းအမြစ်များ
အောက်ဖော်ပြပါ သင်ခန်းစာများသည် Matplotlib ရှိ အခြားသော ဘုံလုပ်ဆောင်ချက်များကို မည်သို့လုပ်ဆောင်ရမည်ကို ရှင်းပြသည်-
Matplotlib ရှိ ဒဏ္ဍာရီတစ်ခု၏ အနေအထားကို မည်သို့ပြောင်းလဲမည်နည်း။
Matplotlib ဇာတ်ကွက်၏ အပြင်ဘက်တွင် ဒဏ္ဍာရီကို မည်သို့ထားမည်နည်း။
Matplotlib တွင် ဒဏ္ဍာရီဖောင့်အရွယ်အစားကို မည်သို့ပြောင်းလဲမည်နည်း။