R တွင် clustered barplot တစ်ခုကို ဖန်တီးနည်း (ဥပမာများဖြင့်)


အုပ်စုဖွဲ့ထားသော barplot သည် အခြားသော variable များဖြင့် အုပ်စုဖွဲ့ထားသော မတူညီသော variable များ၏ အရေအတွက်ကို ပြသသည့် ဇယားအမျိုးအစားတစ်ခုဖြစ်သည်။

ဤသင်ခန်းစာတွင် ggplot2 data visualization library ကို အသုံးပြု၍ R တွင် အစုလိုက်အပြုံလိုက် barplot များဖန်တီးနည်းကို ရှင်းပြထားသည်။

Barplot ကို 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))

#view data frame
df

  team position points
1 A Guard 14
2 A Forward 8
3 A Center 8
4 B Guard 16
5 B Forward 3
6 B Center 7
7 C Guard 17
8 C Forward 22
9C Center 26

အသင်းနှင့် ရာထူးအလိုက် အုပ်စုဖွဲ့ထားသော ကစားသမားတစ်ဦးစီမှ ရမှတ်များကို ပြသသည့် အုပ်စုဖွဲ့ barplot တစ်ခုကို ဖန်တီးရန် အောက်ပါကုဒ်ကို အသုံးပြုနိုင်ပါသည်။

 library (ggplot2)

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

R တွင် Clustered Barplot

အုပ်စုဖွဲ့ Barplot ကို စိတ်ကြိုက်ပြင်ဆင်ခြင်း။

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

 library (ggplot2)

ggplot(df, aes (fill=position, y=points, x=team)) + 
  geom_bar(position=' dodge ', stat=' identity ') +
  theme_minimal() + 
  labs(x=' Team ', y=' Points ', title=' Avg. Points Scored by Position & Team ') +
  theme(plot.title = element_text (hjust=0.5, size=20, face=' bold ')) +
  scale_fill_manual(' Position ', values=c(' coral2 ', ' steelblue ', ' pink '))

R တွင် ggplot2 ဖြင့် Clustered Barplot

ggthemes ဒစ် ဂျစ်တိုက်မှ အပြင်အဆင်များထဲမှ တစ်ခုကို အသုံးပြုခြင်းဖြင့် အသွင်အပြင်ကို စိတ်ကြိုက်ပြင်ဆင်နိုင်ပါသည်။ ဥပမာအားဖြင့်၊ ကျွန်ုပ်တို့သည် ဤစာကြည့်တိုက်မှ Wall Street Journal အပြင်အဆင်ကို အသုံးပြုနိုင်သည်။

 install.packages ('ggthemes')

library (ggplot2)
library (ggthemes)

ggplot(df, aes (fill=position, y=points, x=team)) + 
  geom_bar(position=' dodge ', stat=' identity ') +
  theme_wsj() 

ggthemes ဖြင့် R တွင် Barplot ကို Clustered

နောက်ထပ်အပြင်အဆင်များအတွက် အကောင်းဆုံး ggplot2 အပြင်အဆင်များအတွက် ကျွန်ုပ်တို့၏အပြည့်အစုံလမ်းညွှန်ကို ကိုးကားပါ။

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

R တွင် stacked barplot ဖန်တီးနည်း
ggplot2 ကို အသုံးပြု၍ R တွင် အုပ်စုဖွဲ့ထားသော boxplot တစ်ခုကို ဖန်တီးနည်း
ggplot2 တွင် ဘေးချင်းကပ်ကွက်များ ဖန်တီးနည်း

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

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