Ggplot2 တွင် ဒဏ္ဍာရီတစ်ခုကို ဖယ်ရှားနည်း (ဥပမာများနှင့်အတူ)


ggplot2 ရှိ ကွက်ကွက်တစ်ခုမှ ဒဏ္ဍာရီတစ်ခုကို ဖယ်ရှားရန် အောက်ပါ syntax ကို သင်သုံးနိုင်သည်။

 ggplot(df, aes (x=x, y=y, color=z)) +
  geom_point() +
  theme( legend.position =" none ")

legend.position=”none” ကို သတ်မှတ်ခြင်းဖြင့် သင်သည် ggplot2 ကို ဇာတ်ကွက်မှ ဒဏ္ဍာရီ အားလုံးကို ဖယ်ရှားရန် ပြောနေသည်။

အောက်ဖော်ပြပါ အဆင့်ဆင့် ဥပမာသည် ဤ syntax ကို လက်တွေ့တွင် မည်သို့အသုံးပြုရမည်ကို ပြသထားသည်။

အဆင့် 1: ဒေတာဘောင်ကိုဖန်တီးပါ။

ပထမဦးစွာ၊ ဒေတာဘောင်တစ်ခုဖန်တီးကြပါစို့။

 #create data frame
df <- data. frame (assists=c(3, 4, 4, 3, 1, 5, 6, 7, 9),
                 points=c(14, 8, 8, 16, 3, 7, 17, 22, 26),
                 position=rep(c('Guard', 'Forward', 'Center'), times= 3 ))

#view data frame
df

  assist points position
1 3 14 Guard
2 4 8 Forward
3 4 8 Center
4 3 16 Guard
5 1 3 Forward
6 5 7 Center
7 6 17 Guard
8 7 22 Forward
9 9 26 Center

အဆင့် 2- ggplot2 ကို အသုံးပြု၍ ကွက်ကွက်ဖန်တီးပါ။

ထို့နောက်၊ ရိုးရှင်းသော scatterplot ဖန်တီးရန် ggplot2 ကိုသုံးကြပါစို့။

 library (ggplot2)

#create scatterplot
ggplot(df, aes (x=assists, y=points, color=position)) +
  geom_point(size= 3 )

မူရင်းအားဖြင့်၊ ggplot2 တွင် scatterplot တွင်အရောင်များကိုပိုမိုလွယ်ကူစွာအဓိပ္ပာယ်ဖွင့်ဆိုရန်ဒဏ္ဍာရီတစ်ခုပါရှိသည်။

အဆင့် 3- Plot Legend ကို ဖယ်ရှားပါ။

ထို့နောက်၊ ဇာတ်ကွက်မှဒဏ္ဍာရီကိုဖယ်ရှားရန် legend.position=”none” ကိုသုံးကြပါစို့။

 library (ggplot2)

#create scatterplot with no legend
ggplot(df, aes (x=assists, y=points, color=position)) +
  geom_point(size= 3 ) +
  theme( legend.position =" none ") 

ဒဏ္ဍာရီကို ဇာတ်ကြောင်းမှ လုံးဝဖယ်ရှားခဲ့သည်။

ဆက်စပ်- ggplot2 တွင် ဒဏ္ဍာရီအညွှန်းများကို မည်သို့ပြောင်းရမည်နည်း။

ထပ်လောင်းအရင်းအမြစ်များ

အောက်ဖော်ပြပါ သင်ခန်းစာများသည် ggplot2 တွင် အခြားဘုံလုပ်ဆောင်ချက်များကို မည်သို့လုပ်ဆောင်ရမည်ကို ရှင်းပြသည်-

ggplot2 တွင်ဒဏ္ဍာရီခေါင်းစဉ်ကိုဘယ်လိုပြောင်းမလဲ။
ggplot2 တွင် ဒဏ္ဍာရီအရွယ်အစားကို မည်သို့ပြောင်းလဲမည်နည်း။
ggplot2 တွင် ဒဏ္ဍာရီ အနေအထားကို ဘယ်လိုပြောင်းမလဲ။

မှတ်ချက်တစ်ခုထည့်ပါ။

သင့် email လိပ်စာကို ဖော်ပြမည် မဟုတ်ပါ။ လိုအပ်သော ကွက်လပ်များကို * ဖြင့်မှတ်သားထားသည်