R plots တွင် axis scale ကိုဘယ်လိုပြောင်းမလဲ (ဥပမာများဖြင့်)
မကြာခဏဆိုသလို R ကွက်များတွင် ဝင်ရိုးတစ်ခုပေါ်တွင်အသုံးပြုသောစကေးကို သင်ပြောင်းလိုပေမည်။
ဤသင်ခန်းစာသည် အခြေခံ R နှင့် ggplot2 ကွက်များတွင် ဝင်ရိုးစကေးများကို မည်သို့ပြောင်းလဲရမည်ကို ရှင်းပြထားသည်။
ဥပမာ 1- R ဒေတာဘေ့စ်ရှိ ဝင်ရိုးစကေးများကို မွမ်းမံပါ။
R-based ကွက်တစ်ခုတွင် ဝင်ရိုးစကေးများကို ပြောင်းလဲရန်၊ xlim() နှင့် ylim() လုပ်ဆောင်ချက်များကို သင်အသုံးပြုနိုင်ပါသည်။
အောက်ပါကုဒ်သည် ဤလုပ်ဆောင်ချက်များကို လက်တွေ့တွင် မည်သို့အသုံးပြုရမည်ကို ပြသသည်-
#define data df <- data. frame (x=c(1, 3, 3, 4, 6, 8, 12, 13, 15, 18, 21, 22), y=c(13, 15, 9, 17, 22, 25, 29, 35, 39, 44, 45, 40)) #create plot with default axis scales plot(df$x, df$y, pch=19, main=' Default Axes ') #create plot with custom axis scales plot(df$x, df$y, pch=19, xlim=c(0.30), ylim=c(0.150), main=' Custom Axes ')
log argument ကို အသုံးပြု၍ axes များထဲမှ တစ်ခုကို logarithmic scale သို့ လျင်မြန်စွာ ပြောင်းလဲနိုင်သည်ကို သတိပြုပါ။ ဥပမာအားဖြင့်၊ အောက်ပါကုဒ်သည် Y ဝင်ရိုးအား လော့ဂရစ်သမ်စကေးအဖြစ်သို့ ပြောင်းလဲပုံကို ပြသသည်-
#define data df <- data. frame (x=c(1, 3, 3, 4, 6, 8, 12, 13, 15, 18, 21, 22), y=c(13, 15, 9, 17, 22, 25, 29, 35, 39, 44, 45, 40)) #create plot with log y-axis plot(df$x, df$y, log=' y ', pch=19)
ဥပမာ 2- ggplot2 တွင် ဝင်ရိုးစကေးများကို ပြောင်းပါ။
R-based ကွက်တစ်ခုရှိ ဝင်ရိုးစကေးများကို ပြောင်းလဲရန်၊ ဝင်ရိုးစကေးများကို ပြောင်းလဲရန် xlim() နှင့် ylim() လုပ်ဆောင်ချက်များကို သင်အသုံးပြုနိုင်သည်။
အောက်ပါကုဒ်သည် ဤလုပ်ဆောင်ချက်များကို လက်တွေ့တွင် မည်သို့အသုံးပြုရမည်ကို ပြသသည်-
library (ggplot2) #define data df <- data. frame (x=c(1, 3, 3, 4, 6, 8, 12, 13, 15, 18, 21, 22), y=c(13, 15, 9, 17, 22, 25, 29, 35, 39, 44, 45, 40)) #create scatterplot with custom axes ggplot(data=df, aes(x=x, y=y)) + geom_point() + xlim(0, 30) + ylim(0, 150)
အောက်ဖော်ပြပါ အကြောင်းပြချက်များကို အသုံးပြု၍ ဝင်ရိုးနှစ်ခုလုံးကို လော့ဂရစ်သမ်စကေးအဖြစ် ပြောင်းလဲနိုင်သည်။
- scale_x_continuous(trans=’log10′)
- scale_y_continuous(trans=’log10′)
ဥပမာအားဖြင့်၊ အောက်ပါကုဒ်သည် Y ဝင်ရိုးအား လော့ဂရစ်သမ်စကေးအဖြစ်သို့ ပြောင်းလဲပုံကို ပြသသည်-
library (ggplot2) #define data df <- data. frame (x=c(1, 3, 3, 4, 6, 8, 12, 13, 15, 18, 21, 22), y=c(13, 15, 9, 17, 22, 25, 29, 35, 39, 44, 45, 40)) #create scatterplot with log y-axis ggplot(data=df, aes(x=x, y=y)) + geom_point() + scale_y_continuous(trans=' log10 ')
ဤစာမျက်နှာတွင် R ဒေတာအမြင်ပုံဖော်ခြင်းဆိုင်ရာ သင်ခန်းစာများကို သင်တွေ့နိုင်သည်။