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


ggplot2 ဒဏ္ဍာရီတွင် ဒြပ်စင်များ၏ အရွယ်အစားကို ပြောင်းလဲရန် အောက်ပါ syntax ကို သင် အသုံးပြုနိုင်ပါသည်။

 ggplot(data, aes (x=x, y=y)) +
  theme( legend.key.size = unit(1, ' cm '), #change legend key size
legend.key.height = unit(1, ' cm '), #change legend key height
        legend.key.width = unit(1, ' cm '), #change legend key width
legend.title = element_text(size=14), #change legend title font size
        legend.text = element_text(size=10)) #change legend text font size

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

ggplot2 ဂန္တဝင်သော့အရွယ်အစားကို ပြောင်းပါ။

ggplot2 ကိုအသုံးပြု၍ အောက်ပါ အုပ်စုဖွဲ့ထားသော barplot ကို ဖန်တီးသည်ဆိုပါစို့။

 library (ggplot2)

#create data frame
df <- data.frame(team=rep(c(' A ', ' B ', ' C '), each =3),
                 position=rep(c(' Guard ', ' Forward ', ' Center '), times =3),
                 dots=c(14, 8, 8, 16, 3, 7, 17, 22, 26))

#create grouped barplot
ggplot(df, aes (fill=position, y=points, x=team)) +
  geom_bar(position=' dodge ', stat=' identity ') 

မူရင်းအားဖြင့်၊ ggplot2 သည် ဂရပ်၏ညာဘက်တွင် ဒဏ္ဍာရီကို ပေးသည်။

ဒဏ္ဍာရီသော့များကို ချဲ့ရန်အတွက် အောက်ပါကုဒ်သည် legend.key.size အငြင်းအခုံကို အသုံးပြုပုံကို ပြသည်-

 ggplot(df, aes (fill=position, y=points, x=team)) +
  geom_bar(position=' dodge ', stat=' identity ') +
  theme( legend.key.size = unit(2, ' cm ')) 

ggplot2 တွင် ဒဏ္ဍာရီအရွယ်အစားကို ပြောင်းပါ။

သော့အနံနှင့် အမြင့်များကို သတ်မှတ်ရန် legend.key.width နှင့် legend.key.height အငြင်းအခုံများကိုလည်း အသုံးပြုနိုင်ပါသည်။

 ggplot(df, aes (fill=position, y=points, x=team)) +
  geom_bar(position=' dodge ', stat=' identity ') +
  theme( legend.key.height = unit(2, ' cm '),
        legend.key.width = unit(4, ' cm ')) 

ggplot2 တွင် ဂန္တဝင်သော့အရွယ်အစားကို ပြောင်းပါ။

ဒဏ္ဍာရီခေါင်းစဉ်ဖောင့်အရွယ်အစား ggplot2 ကိုပြောင်းပါ။

ဒဏ္ဍာရီခေါင်းစဉ်၏ ဖောင့်အရွယ်အစားကို ချဲ့ရန် legend.title အငြင်းအခုံကို သုံး နိုင်သည်

 ggplot(df, aes (fill=position, y=points, x=team)) +
  geom_bar(position=' dodge ', stat=' identity ') +
  theme( legend.title = element_text(size=30)) 

ဒဏ္ဍာရီခေါင်းစဉ်ဖောင့်အရွယ်အစား ggplot2 ကိုပြောင်းပါ။

ဒဏ္ဍာရီစာသားဖောင့်အရွယ်အစား ggplot2 ကိုပြောင်းပါ။

ဒဏ္ဍာရီခေါင်းစဉ်၏ ဖောင့်အရွယ်အစားကို ချဲ့ရန် legend.text အငြင်းအခုံကို သုံးနိုင်သည်-

 ggplot(df, aes (fill=position, y=points, x=team)) +
  geom_bar(position=' dodge ', stat=' identity ') +
  theme( legend.text = element_text(size=30)) 

ggplot2 တွင် ဒဏ္ဍာရီစာသားအရွယ်အစားကို ပြောင်းပါ။

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

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

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

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