Ggplot2 တွင် facet axis အညွှန်းများကိုဘယ်လိုပြောင်းမလဲ။


ggplot2 တွင် facet ဝင်ရိုးအညွှန်းများကိုပြောင်းလဲရန် as_labeller() လုပ်ဆောင်ချက်ကို သင်အသုံးပြုနိုင်သည်-

 ggplot(df, aes(x, y)) + 
  geom_point() +
  facet_wrap(.~group,
             strip. position = ' left ', 
             labeller = as_labeller(c(A=' new1 ', B=' new2 ', C=' new3 ', D=' new4 '))) +
  ylab(NULL) +
  theme(strip. background = element_blank(),
        strip. placement ='outside')

ဤဥပမာသည် အောက်ပါအညွှန်းဟောင်းများကို အစားထိုးသည်-

  • အဘေီစီဒီ

အောက်ပါတံဆိပ်အသစ်များဖြင့်

  • အသစ် ၁၊ အသစ် ၂၊ အသစ် ၃၊ အသစ် ၄

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

ဥပမာ- ggplot2 တွင် Facet Axis Labels များကို တည်းဖြတ်ပါ။

R တွင် အောက်ပါ data frame ရှိသည်ဆိုပါစို့။

 #create data frame
df <- data. frame (team=c('A', 'A', 'B', 'B', 'C', 'C', 'D', 'D'),
                 points=c(8, 14, 20, 22, 25, 29, 30, 31),
                 assists=c(10, 5, 5, 3, 8, 6, 9, 12))

#view data frame
df

  team points assists
1 to 8 10
2 to 14 5
3 B 20 5
4 B 22 3
5 C 25 8
6 C 29 6
7 D 30 9
8 D 31 12

အောက်ပါကုဒ်သည် အဖွဲ့တစ်ခုစီအတွက် assss နှင့် point များကိုပြသသည့် grid တစ်ခုဖန်တီးရန် facet_wrap() ကိုအသုံးပြုပုံကိုပြသသည်-

 library (ggplot2)

#create multiple scatter plots using facet_wrap
ggplot(df, aes (assists, points)) +
  geom_point() +
  facet_wrap(.~team, nrow= 4 )

လက်ရှိတွင် facets တွင် အောက်ပါအညွှန်းများရှိသည်- A၊ B၊ C၊ D။

သို့သော်၊ Team A၊ Team B၊ Team C နှင့် Team D တံဆိပ်များကို ပြောင်းလဲရန် အောက်ပါကုဒ်များကို ကျွန်ုပ်တို့ အသုံးပြုနိုင်ပါသည်။

 library (ggplot2)

#create multiple scatter plots using facet_wrap with custom facet labels
ggplot(df, aes(assists, points)) + 
  geom_point() +
  facet_wrap(.~team, nrow= 4 ,
             strip. position = ' left ', 
             labeller = as_labeller(c(A=' team A ',
                                      B=' team B ',
                                      C=' team C ',
                                      D=' team D '))) +
  ylab(NULL) +
  theme(strip. background = element_blank(),
        strip. placement = ' outside ')

ggplot2 သည် facet ဝင်ရိုးအညွှန်းများကို ပြောင်းသည်။

အသွင်အပြင်တံဆိပ်များကို Team A၊ Team B၊ Team C နှင့် Team D သို့ ပြောင်းထားပြီး ကွက်လပ်၏ ဘယ်ဘက်ခြမ်းသို့ ရွှေ့ထားကြောင်း သတိပြုပါ။

မှတ်ချက်strip.background argument သည် facet တံဆိပ်များနောက်ကွယ်ရှိ မီးခိုးရောင်နောက်ခံကို ဖယ်ရှားပြီး strip.placement argument မှ တံဆိပ်များကို ဝင်ရိုးအမှတ်အသားများအပြင်ဘက်တွင် ထားရှိသင့်သည်ဟု သတ်မှတ်သည်။

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

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

ggplot2 တွင် facets ၏အစီစဥ်ကိုဘယ်လိုပြောင်းမလဲ။
ggplot2 မှာ ဖောင့်အရွယ်အစားကို ဘယ်လိုပြောင်းမလဲ။
ggplot2 တွင် ဝင်ရိုးတံဆိပ်များကို လှည့်နည်း

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

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