Ggplot2 တွင် အနားသတ်များကို မည်သို့ပြောင်းလဲနည်း (ဥပမာများဖြင့်)


ကွက်ကွက်တစ်ခု၏အနားသတ်ဧရိယာများကိုမွမ်းမံရန် ggplot2 တွင် theme() argument ကိုသုံးနိုင်သည်။

 ggplot(df, aes(x=x)) + 
  geom_histogram() +
  theme(plot. margin =unit(c(5,1,1,1), ' cm '))

ကွက်ကွက်အနားသတ်အစီအစဥ်မှာ အောက်ပါအတိုင်းဖြစ်ကြောင်း မှတ်သားထားပါ။

  • ယူနစ်(c(အပေါ်၊ ညာ၊ အောက်၊ ဘယ်၊ ဘယ်)၊ ယူနစ်)

အောက်ဖော်ပြပါ ဥပမာများသည် လက်တွေ့တွင် ggplot2 ကွက်များ၏ အနားသတ်ဧရိယာများကို မည်သို့ပြောင်းလဲရမည်ကို ပြသထားသည်။

ဥပမာ 1- အခြေခံဇာတ်ကွက်ဖန်တီးပါ။

အောက်ဖော်ပြပါကုဒ်သည် အနားသတ်ဧရိယာများကို မသတ်မှတ်ဘဲ ggplot2 တွင် အခြေခံကြံစည်မှုတစ်ခုဖန်တီးနည်းကို ပြသသည်-

 library (ggplot2)

#make this example reproducible
set. seeds (0)

#create data
df <- data. frame (x=rnorm(n= 5000 ))

#create histogram using ggplot2
ggplot(df, aes(x=x)) + 
  geom_histogram() +
  ggtitle(' Title of Histogram ') +
  theme(plot. background =element_rect(fill=' #e3fbff '))

ဇာတ်ကွက်တစ်ခုစီတွင် အနားသတ်အနည်းငယ်သာရှိကြောင်း သတိပြုပါ။

ဥပမာ 2- ကွက်ကွက်အနားသတ်များကို ပြောင်းပါ။

အောက်ပါကုဒ်သည် ကွက်ကွက်၏အပေါ်နှင့်အောက်ခြေတွင် သိသာထင်ရှားသောအနားသတ်များကို ထည့်သွင်းနည်းကို ပြသသည်-

 library (ggplot2)

#make this example reproducible
set. seeds (0)

#create data
df <- data. frame (x=rnorm(n= 5000 ))

#create histogram with significant margins on top and bottom
ggplot(df, aes(x=x)) + 
  geom_histogram() +
  ggtitle(' Title of Histogram ') +
  theme(plot. margin =unit(c(5,1,5,1), ' cm '),
        plot. background =element_rect(fill=' #e3fbff ')) 

ဇာတ်ကွက်၏အပေါ်နှင့်အောက်ခြေတွင် နေရာလွတ်များ သိသာထင်ရှားစွာရှိနေသည်ကို သတိပြုပါ။

အောက်ဖော်ပြပါကုဒ်သည် ကွက်ကွက်၏ဘယ်နှင့်ညာဘက်တွင် သိသာထင်ရှားသောအနားသတ်များထည့်နည်းကိုပြသသည်-

 library (ggplot2)

#make this example reproducible
set. seeds (0)

#create data
df <- data. frame (x=rnorm(n= 5000 ))

#create histogram with significant margins on left and right
ggplot(df, aes(x=x)) + 
  geom_histogram() +
  ggtitle(' Title of Histogram ') +
  theme(plot. margin =unit(c(1,5,1,5), ' cm '),
        plot. background =element_rect(fill=' #e3fbff ')) 

ggplot2 အနားသတ်များဖြင့် ကွက်ကွက်

ဇာတ်ကွက်၏ ဘယ်နှင့်ညာတွင် နေရာအမြောက်အမြားရှိကြောင်း သတိပြုပါ။

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

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

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

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

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