Ggplot2 ရှိ x ဝင်ရိုးပေါ်ရှိ ပစ္စည်းများ မှာယူနည်း
ggplot2 ရှိ ကွက်ကွက်တစ်ခု၏ x-axis ပေါ်ရှိ အရာများကို မှာယူရန် အောက်ပါအခြေခံ syntax ကို အသုံးပြုနိုင်ပါသည်။
ggplot(df, aes(x=factor(x_var, level=c(' value1 ', ' value2 ', ' value3 ')), y=y_var)) + geom_col()
အောက်ဖော်ပြပါ ဥပမာများသည် ဤ syntax ကို လက်တွေ့တွင် မည်သို့အသုံးပြုရမည်ကို ပြသထားသည်။
ဥပမာ- ggplot2 ရှိ x-axis တွင် ပစ္စည်းများကို မှာယူပါ။
မတူညီသောဘတ်စကက်ဘောအသင်းများမှ ရမှတ်များကိုပြသသည့် R တွင် အောက်ပါဒေတာဘောင်ရှိသည်ဆိုပါစို့။
#create data frame
df <- data. frame (team=c('Mavs', 'Heat', 'Nets', 'Lakers'),
dots=c(100, 122, 104, 109))
#view data frame
df
team points
1 Mavs 100
2 Heat 122
3 Nets 104
4 Lakers 109
အဖွဲ့တစ်ခုစီမှ ရမှတ်များကို မြင်သာစေရန် ဘားဇယားတစ်ခုကို ဖန်တီးပါက၊ ggplot2 သည် ဘားများကို အက္ခရာစဉ်အလိုက် အလိုအလျောက်စီမည်-
library (ggplot2) #create bar plot ggplot(df, aes(x=team, y=points)) + geom_col()
x-axis ပေါ်ရှိ bars များအတွက် အမှာစာတစ်ခု သတ်မှတ်ရန်၊ level argument ကို အောက်ပါအတိုင်း အသုံးပြုနိုင်ပါသည်။
library (ggplot2) #create bar plot with specific axis order ggplot(df, aes(x=factor(team, level=c(' Mavs ', ' Heat ', ' Nets ', ' Lakers ')), y=points)) + geom_col()
အဆင့် အငြင်းပွားမှုတွင် ကျွန်ုပ်တို့သတ်မှတ်ထားသော ဘားများသည် အတိအကျအစီအစဥ်အတိုင်းဖြစ်နေပါပြီ။
x-axis ကို ဖတ်ရပိုလွယ်သည့်အရာအဖြစ် ပြောင်းလဲရန် xlab() ကို အသုံးပြုနိုင်သည်။
library (ggplot2) #create bar plot with specific axis order ggplot(df, aes(x=factor(team, level=c(' Mavs ', ' Heat ', ' Nets ', ' Lakers ')), y=points)) + geom_col() + xlab(' Team ')
ထပ်လောင်းအရင်းအမြစ်များ
အောက်ဖော်ပြပါ သင်ခန်းစာများသည် ggplot2 တွင် အခြားဘုံအလုပ်များကို မည်သို့လုပ်ဆောင်ရမည်ကို ရှင်းပြသည်-
ggplot2 တွင် ဝင်ရိုးတံဆိပ်များကို လှည့်နည်း
ggplot2 တွင် ဝင်ရိုးကွဲများကို သတ်မှတ်နည်း
ggplot2 တွင် ဝင်ရိုးကန့်သတ်ချက်များကို မည်သို့သတ်မှတ်မည်နည်း။
ggplot2 တွင် ဒဏ္ဍာရီအညွှန်းများကို မည်သို့ပြောင်းရမည်နည်း။