လိုင်းများစွာဖြင့် ggplot2 တွင် ဒဏ္ဍာရီတစ်ခုကို ဖန်တီးနည်း
ggplot2 တွင် စာကြောင်းများစွာဖြင့် ဒဏ္ဍာရီတစ်ခုကို ဖန်တီးရန် အောက်ပါ syntax ကို သင်အသုံးပြုနိုင်သည်-
ggplot(df, aes(x=x_var, y=y_var, color=group_var)) + geom_point() + guides(color=guide_legend(nrow= 2 , byrow= TRUE ))
nrow အငြင်းအခုံ၏တန်ဖိုးသည် ဒဏ္ဍာရီတွင်အသုံးပြုရမည့် လိုင်းအရေအတွက်ကို သတ်မှတ်သည်။
အောက်ဖော်ပြပါ ဥပမာသည် ဤ syntax ကို လက်တွေ့တွင် မည်သို့အသုံးပြုရမည်ကို ပြသထားသည်။
ဥပမာ- စာကြောင်းများစွာဖြင့် ggplot2 တွင် ဒဏ္ဍာရီတစ်ခုကို ဖန်တီးပါ။
R တွင် ဘတ်စကက်ဘောကစားသမားများအကြောင်း အချက်အလက်များစွာပါရှိသော အောက်ပါဒေတာဘောင်ရှိသည်ဆိုပါစို့။
#create data frame df <- data. frame (team=c('Mavs', 'Heat', 'Nets', 'Lakers', 'Suns', 'Cavs'), points=c(24, 20, 34, 39, 28, 29), assists=c(5, 7, 6, 9, 12, 13)) #view data frame df team points assists 1 Mavs 24 5 2 Heat 20 7 3 Nets 34 6 4 Lakers 39 9 5 Suns 28 12 6 Cavs 29 13
အကယ်၍ ကျွန်ုပ်တို့သည် ဒဏ္ဍာရီတွင် အသုံးပြုရန် လိုင်းအရေအတွက်ကို မသတ်မှတ်ဘဲ ggplot2 တွင် scatterplot တစ်ခုကို ဖန်တီးပါက၊ ggplot2 သည် လိုင်းတစ်ခုစီတွင် အညွှန်းတစ်ခုကို ပုံသေသတ်မှတ်ထားလိမ့်မည်-
library (ggplot2)
#create default scatterplot
ggplot(df, aes(x=assists, y=points, color=team)) +
geom_point(size= 3 )
လိုင်းများစွာဖြင့် ဒဏ္ဍာရီတစ်ခုကို ဖန်တီးရန်အတွက် nrow အငြင်းအခုံဖြင့် guides() လုပ်ဆောင်ချက်ကို အသုံးပြုရန် လိုအပ်သည်-
library (ggplot2)
#create scatterplot with two rows in legend
ggplot(df, aes(x=assists, y=points, color=team)) +
geom_point(size= 3 ) +
guides(color=guide_legend(nrow= 2 , byrow= TRUE ))
ဒဏ္ဍာရီမှာ စာကြောင်းနှစ်ကြောင်းရှိတယ်ဆိုတာ သတိပြုပါ။
ဒဏ္ဍာရီ၏တည်နေရာကိုလည်း ပြောင်းလဲလိုပါက၊ Legend.position အငြင်းအခုံဖြင့် theme() လုပ်ဆောင်ချက်ကို အသုံးပြုနိုင်ပါသည်။
library (ggplot2)
#create scatterplot with two rows in legend
ggplot(df, aes(x=assists, y=points, color=team)) +
geom_point(size= 3 ) +
theme(legend. position = ' bottom ') +
guides(color=guide_legend(nrow= 2 , byrow= TRUE ))
ဒဏ္ဍာရီသည် ယခုအခါ ဇာတ်ကွက်၏အောက်ခြေတွင် တည်ရှိပြီး စာကြောင်းနှစ်ကြောင်းရှိသည်။
ထပ်လောင်းအရင်းအမြစ်များ
အောက်ဖော်ပြပါ သင်ခန်းစာများသည် ggplot2 တွင် အခြားသော ဘုံလုပ်ဆောင်ချက်များကို မည်သို့လုပ်ဆောင်ရမည်ကို ရှင်းပြသည်-
ggplot2 တွင်ဒဏ္ဍာရီခေါင်းစဉ်ကိုဘယ်လိုပြောင်းမလဲ။
ggplot2 တွင် ဒဏ္ဍာရီအရွယ်အစားကို မည်သို့ပြောင်းလဲမည်နည်း။
ggplot2 တွင် ဒဏ္ဍာရီ အနေအထားကို ဘယ်လိုပြောင်းမလဲ။