Seaborn မြေကွက်များတွင် ဝင်ရိုးတံဆိပ်များကို လှည့်နည်း
Seaborn ကွက်ကွက်တွင် ဝင်ရိုးအညွှန်းများကို လှည့်ရန် အောက်ပါအခြေခံ syntax ကို သင်အသုံးပြုနိုင်သည်-
my_plot. set_xticklabels ( my_plot.get_xticklabels (), rotation= 45 )
အောက်ဖော်ပြပါ ဥပမာသည် ဤ syntax ကို လက်တွေ့တွင် မည်သို့အသုံးပြုရမည်ကို ပြသထားသည်။
ဥပမာ- Seaborn Plot တွင် ဝင်ရိုးတံဆိပ်များကို လှည့်နည်း
မတူညီသောအသင်းများမှ ဘတ်စကက်ဘောကစားသမားများမှ ရမှတ်များအကြောင်း အချက်အလက်ပါရှိသော အောက်ပါပန်ဒါ DataFrame ရှိသည်ဆိုပါစို့။
import pandas as pd
#createDataFrame
df = pd. DataFrame ({' team ': ['Mavericks', 'Mavericks', 'Mavericks',
'Mavericks', 'Warriors', 'Warriors',
'Blazers', 'Blazers', 'Kings',
'some_really_really_long_name'],
' points ': [22, 14, 9, 7, 29, 20, 30, 34, 19, 12]})
#view DataFrame
print (df)
team points
0 Mavericks 22
1 Mavericks 14
2 Mavericks 9
3 Mavericks 7
4 Warriors 29
5 Warriors 20
6 Blazers 30
7 Blazers 34
8 Kings 19
9 some_really_really_long_name 12
DataFrame တွင် အဖွဲ့တစ်ခုစီ၏ အရေအတွက်ကိုပြသသည့် ကွက်ကွက်တစ်ခုဖန်တီးရန် seaborn ရှိ countplot() လုပ်ဆောင်ချက်ကို အသုံးပြုနိုင်ပါသည်။
import seaborn as sns #create seaborn countplot my_plot = sns. countplot (data=df, x=' team ')
အသင်းအမည်များထဲမှတစ်ခုသည် အလွန်ရှည်သောကြောင့်၊ ၎င်းသည် x-axis ရှိ အခြားအသင်းအမည်နှင့် ထပ်နေပါသည်။
ဤပြဿနာကို ဖြေရှင်းရန်အတွက်၊ ကျွန်ုပ်တို့သည် X ဝင်ရိုးအညွှန်းများကို လှည့်ရန် အောက်ပါကုဒ်ကို အသုံးပြုနိုင်ပါသည်။
import seaborn as sns #create seaborn countplot my_plot = sns. countplot (data=df, x=' team ') #rotate x-axis labels my_plot. set_xticklabels ( my_plot.get_xticklabels (), rotation= 45 )
X ဝင်ရိုးအညွှန်းတစ်ခုစီကို ယခု 45 ဒီဂရီလှည့်ထားကြောင်း သတိပြုပါ။
ကျွန်ုပ်တို့အလိုရှိပါက၊ ကျွန်ုပ်တို့သည် x-axis အညွှန်းများကို ဘယ်ဘက်သို့ပြောင်းရန် အလျားလိုက် ချိန်ညှိမှု အငြင်းအခုံကို အသုံးပြုနိုင်သည်။
import seaborn as sns #create seaborn countplot my_plot = sns. countplot (data=df, x=' team ') #rotate x-axis labels my_plot. set_xticklabels ( my_plot.get_xticklabels (), rotation= 45 , horizontalalignment=' right ')
X ဝင်ရိုးတံဆိပ်တစ်ခုစီကို ၄၅ ဒီဂရီလှည့်ပြီး ဘယ်ဘက်သို့ ရွှေ့ထားသည်။
မှတ်ချက် – အကယ်၍ သင်သည် Jupyter မှတ်စုစာအုပ်သို့ seaborn တင်သွင်းရာတွင် အခက်အခဲရှိနေပါက၊ သင်သည် %pip install seaborn command ကို ဦးစွာလုပ်ဆောင်ရန် လိုအပ်ပါသည်။
ထပ်လောင်းအရင်းအမြစ်များ
အောက်ဖော်ပြပါ သင်ခန်းစာများသည် Seaborn တွင် အခြားဘုံအလုပ်များကို မည်သို့လုပ်ဆောင်ရမည်ကို ရှင်းပြသည်-
Seaborn Plots တွင် ခေါင်းစဉ်တစ်ခုထည့်နည်း
Seaborn ကွက်များတွင် ဖောင့်အရွယ်အစားကို မည်သို့ပြောင်းရမည်နည်း။
Seaborn ဇာတ်ကွက်၏ ပုံအရွယ်အစားကို ချိန်ညှိနည်း