Ggplot2 တွင် ပွင့်လင်းသော နောက်ခံကို အသုံးပြုနည်း
ggplot2 ရှိ ကွက်ကွက်တစ်ခုတွင် ပွင့်လင်းမြင်သာသော နောက်ခံတစ်ခုကို ဖန်တီးရန် အောက်ပါ syntax ကို အသုံးပြုနိုင်သည်။
p+ theme( panel. background = element_rect(fill=' transparent '), #transparent panel bg plot. background = element_rect(fill=' transparent ', color= NA ), #transparent plot bg panel. grid . major = element_blank(), #remove major gridlines panel. grid . minor = element_blank(), #remove minor gridlines legend. background = element_rect(fill=' transparent '), #transparent legend bg legend. box . background = element_rect(fill=' transparent ') #transparent legend panel )
ggsave() ကို အသုံးပြု၍ ဇာတ်ကွက်ကို တင်ပို့ရန် ဆုံးဖြတ်ပါက၊ နောက်ခံသည် ပွင့်လင်းမြင်သာမှုရှိရန် သေချာစေပါ။
ggsave(' myplot.png ' , p, bg = ' transparent ' )
အောက်ဖော်ပြပါ ဥပမာသည် ဤ syntax ကို လက်တွေ့တွင် မည်သို့အသုံးပြုရမည်ကို ပြသထားသည်။
ဥပမာ- ggplot2 တွင် ပွင့်လင်းသော နောက်ခံကို အသုံးပြုခြင်း။
အောက်ပါကုဒ်သည် ggplot2 တွင် ရိုးရှင်းသော အုပ်စုဖွဲ့ထားသော boxplot တစ်ခုကို ဖန်တီးနည်းကို ပြသသည်-
library (ggplot2) #make this example reproducible set. seeds (1) #create dataset data <- data. frame (team=rep(c(' A ', ' B ', ' C '), each= 50 ), program=rep(c(' low ', ' high '), each= 25 ), values=seq(1:150)+sample(1:100, 150, replace= TRUE )) #create boxplot ggplot(data, aes (x=team, y=values, fill=program)) + geom_boxplot()
ကွက်ကွက်အတွက် ပွင့်လင်းမြင်သာသော နောက်ခံကို ဖန်တီးရန် အောက်ပါကုဒ်ကို ကျွန်ုပ်တို့ အသုံးပြုနိုင်ပါသည်။
library (ggplot2) #make this example reproducible set. seeds (1) #create dataset data <- data. frame (team=rep(c(' A ', ' B ', ' C '), each= 50 ), program=rep(c(' low ', ' high '), each= 25 ), values=seq(1:150)+sample(1:100, 150, replace= TRUE )) #create boxplot p <- ggplot(data, aes (x=team, y=values, fill=program)) + geom_boxplot() + theme( panel. background = element_rect(fill=' transparent '), plot. background = element_rect(fill=' transparent ', color= NA ), panel. grid . major = element_blank(), panel. grid . minor = element_blank(), legend. background = element_rect(fill=' transparent '), legend. box . background = element_rect(fill=' transparent ') ) #display boxplot p
ထို့နောက် ကျွန်ုပ်တို့သည် ဤလမ်းကြောင်းကို PNG ဖိုင်တစ်ခုသို့ တင်ပို့နိုင်ပြီး တင်ပို့လိုက်သောပုံတွင် နောက်ခံသည် ပွင့်လင်းမြင်သာမှုရှိရမည်ဟု သတ်မှတ်နိုင်သည်-
ggsave(' grouped_boxplot.png ' , p, bg = ' transparent ' )
ကျွန်ုပ်၏ကွန်ပြူတာတွင် ဤထုတ်ယူထားသောဖိုင်ကိုဖွင့်ပါက၊ နောက်ခံသည် ပွင့်လင်းမြင်သာမှုရှိသည်ကို ကျွန်ုပ်တွေ့မြင်ရသည်-
ထပ်လောင်းအရင်းအမြစ်များ
ggplot2 တွင် ဖောင့်အရွယ်အစားကို မည်သို့ပြောင်းလဲမည်နည်း။
ggplot2 တွင်ဒဏ္ဍာရီကိုမည်သို့ဖယ်ရှားနည်း
ggplot2 တွင် gridlines များကိုမည်သို့ဖယ်ရှားနည်း