Ggplot2 တွင် axis breaks သတ်မှတ်နည်း (ဥပမာများနှင့်အတူ)


ggplot2 တွင် y-axis နှင့် x-axis အတွက် ဝင်ရိုး jumps များကို သတ်မှတ်ရန် အောက်ပါ syntax ကို အသုံးပြုနိုင်သည်။

 #set breaks on y-axis
scale_y_continuous(limits = c(0, 100), breaks = c(0, 50, 100))

#set breaks on y-axis
scale_x_continuous(limits = c(0, 10), breaks = c(0, 2, 4, 6, 8, 10))

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

 #create data frame
df <- data. frame (x=c(1, 2, 4, 5, 7, 8, 9, 10),
                 y=c(12, 17, 27, 39, 50, 57, 66, 80))

#view data frame
df

   xy
1 1 12
2 2 17
3 4 27
4 5 39
5 7 50
6 8 57
7 9 66
8 10 80

ဥပမာ 1- Y ဝင်ရိုးပေါ် ခုန်ခြင်းကို သတ်မှတ်ပါ။

အောက်ပါကုဒ်သည် ggplot2 ကို အသုံးပြု၍ ရိုးရှင်းသော scatterplot ဖန်တီးနည်းကို ပြသသည် ။

 library (ggplot2)

#create scatterplot of x vs. y
ggplot(df, aes(x=x, y=y)) +
  geom_point() 

ပုံသေအားဖြင့်၊ Y ဝင်ရိုးသည် 20၊ 40၊ 60၊ နှင့် 80 တွင် break များကိုပြသသည်။ သို့သော်၊ ၎င်းအစား တန်ဖိုး 10 တိုင်းကို breaks ပြရန် scale_y_continuous() လုပ်ဆောင်ချက်ကို ကျွန်ုပ်တို့အသုံးပြုနိုင်သည်-

 #create scatterplot of x vs. y with custom breaks on y-axis
ggplot(df, aes(x=x, y=y)) +
  geom_point() +
  scale_y_continuous(limits = c(0, 100), breaks = seq(0, 100, 10)) 

ဥပမာ 2- X ဝင်ရိုးပေါ် ခုန်ခြင်းကို သတ်မှတ်ပါ။

x-axis တွင် ခေတ္တရပ်နားခြင်းကို သတ်မှတ်ရန် scale_x_continuous() လုပ်ဆောင်ချက်ကို ကျွန်ုပ်တို့ အသုံးပြုနိုင်ပါသည်။

 #create scatterplot of x vs. y with custom breaks on x-axis
ggplot(df, aes(x=x, y=y)) +
  geom_point() +
  scale_x_continuous(limits = c(0, 10), breaks = c(0, 2, 4, 6, 8, 10)) 

ကျွန်ုပ်တို့သည် ယေဘူယျအားဖြင့် ဝင်ရိုးခုန်ခြင်းများကို တူညီသောအကွာအဝေးများတွင် သတ်မှတ်ထားသော်လည်း ဝင်ရိုးခုန်ခြင်းများကို သတ်မှတ်နံပါတ်များဖြင့်သာ ရွေးချယ်နိုင်ပါသည်။

ဥပမာအားဖြင့်၊ အောက်ပါကုဒ်သည် တန်ဖိုးများ 0၊ 7 နှင့် 10 တွင် X ဝင်ရိုးပေါ်တွင် ခုန်ခြင်းကိုပြသနည်းကိုပြသသည်-

 #create scatterplot of x vs. y with custom breaks on x-axis
ggplot(df, aes(x=x, y=y)) +
  geom_point() +
  scale_x_continuous(limits = c(0, 10), breaks = c(0, 7, 10)) 

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

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

ggplot2 တွင် လော့ဂရစ်သမ်စကေးတစ်ခုကို ဖန်တီးနည်း
ggplot2 တွင် ဝင်ရိုးကန့်သတ်ချက်များကို မည်သို့သတ်မှတ်မည်နည်း။
ggplot2 တွင် ဝင်ရိုးတံဆိပ်များကို လှည့်နည်း

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

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