အကောင်းဆုံး ggplot2 အပြင်အဆင်များအတွက် ပြီးပြည့်စုံသော လမ်းညွှန်
ဤသင်ခန်းစာတွင် ပါဝင်သော အကောင်းဆုံး ggplot2 အပြင်အဆင်များအတွက် လမ်းညွှန်ချက်အပြည့်အစုံကို ပေးဆောင်သည်-
- Built-in ggplot2 အပြင်အဆင်များကို အသုံးပြု၍ မြေကွက်များ၏အသွင်အပြင်ကို မည်သို့ပြောင်းလဲမည်နည်း။
- ggthemes ဒစ် ဂျစ်တိုက်မှ ကြိုတင်သတ်မှတ်ထားသည့် အပြင်အဆင်များကို အသုံးပြု၍ ကွက်ကွက်များ၏ အသွင်အပြင်ကို မည်သို့ပြောင်းလဲမည်နည်း။
- လမ်းကြောင်းဘောင် နောက်ခံနှင့် ဂရစ်လိုင်းများ အပါအဝင် အပြင်အဆင်၏ သီးခြားအစိတ်အပိုင်းများကို တည်းဖြတ်နည်း။
Built-in ggplot2 အပြင်အဆင်များကို အသုံးပြု၍ ကွက်ကွက်အသွင်အပြင်ကို မည်သို့ပြောင်းလဲမည်နည်း။
အောက်ဖော်ပြပါ ဥပမာတစ်ခုစီအတွက်၊ ထည့်သွင်းထားသော R ဒေတာအတွဲမှ မျက်ဝန်းကို ကျွန်ုပ်တို့ အသုံးပြုပါမည်-
#view first six rows of iris dataset
head(iris)
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1 5.1 3.5 1.4 0.2 setosa
2 4.9 3.0 1.4 0.2 setosa
3 4.7 3.2 1.3 0.2 setosa
4 4.6 3.1 1.5 0.2 setosa
5 5.0 3.6 1.4 0.2 setosa
6 5.4 3.9 1.7 0.4 setosa
ဦးစွာ၊ ကျွန်ုပ်တို့သည် ggplot2 စာကြည့်တိုက်ကို တင်ပြီး မျိုးစိတ်အလိုက် အရောင်ခြယ်ထားသော y- ဝင်ရိုးပေါ်ရှိ Sepal.Length နှင့် Sepal.Length ကိုပြသမည့် scatterplot ကိုဖန်တီးပါမည် ။
#load ggplot2 library library(ggplot2) #create scatterplot ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width, color = Species)) + geom_point()
ထို့နောက်တွင် ထည့်သွင်းထားသော ggplot2 အပြင်အဆင်တစ်ခုစီသည် ကွက်ကွက်၏အသွင်အပြင်ကို မည်သို့အကျိုးသက်ရောက်ကြောင်းပြသပါမည်။
grey_theme
မီးခိုးရောင်နောက်ခံနှင့် အဖြူရောင်ဇယားဖြင့် မူရင်းအပြင်အဆင်။
ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width, color = Species)) +
geom_point() +
theme_gray()
bw_theme
အဖြူပေါ်တွင် အနက်ရောင် အပြင်အဆင်။
ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width, color = Species)) +
geom_point() +
theme_bw()
theme_linedraw
အဖြူရောင်နောက်ခံတွင် မတူညီသော အကျယ်အဝန်းအနက်ရောင်မျဉ်းများသာရှိသော အပြင်အဆင်။
ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width, color = Species)) +
geom_point() +
theme_linedraw()
အပြင်အဆင်_အလင်း
theme_linedraw နှင့် ဆင်တူသော်လည်း ဒေတာကို ပိုမိုအာရုံစိုက်ရန် ဒီဇိုင်းထုတ်ထားသော မီးခိုးရောင်လိုင်းများနှင့် ပုဆိန်များဖြင့် ပြုလုပ်ထားသည်။
ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width, color = Species)) +
geom_point() +
theme_light()
dark_theme
theme_light နှင့် ဆင်တူသော အပြင်အဆင်၊ မှောင်သော နောက်ခံဖြင့်။ လှပသော ရောင်စုံလိုင်းများ ထုတ်ပေးရန်အတွက် အသုံးဝင်သော ဆောင်ပုဒ်တစ်ခု။
ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width, color = Species)) +
geom_point() +
theme_dark()
minimal_theme
နောက်ခံမှတ်ချက်များမပါဘဲ အပြင်အဆင်။
ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width, color = Species)) +
geom_point() +
theme_minimal()
classic_theme
အကွက်မပါသော အပြင်အဆင်။
ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width, color = Species)) +
geom_point() +
theme_classic()
အပြင်အဆင်_ပျက်ပြယ်သည်။
လုံးဝအလွတ်ရနေတဲ့ အပြင်အဆင်။
ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width, color = Species)) +
geom_point() +
theme_void()
ggthemes ဒစ်ဂျစ်တိုက်မှ ကြိုတင်သတ်မှတ်ထားသည့် အပြင်အဆင်များကို အသုံးပြု၍ ကွက်ကွက်များ၏ အသွင်အပြင်ကို မည်သို့ပြောင်းလဲမည်နည်း။
Built-in ggplot2 အပြင်အဆင်များကို အသုံးပြုခြင်းအပြင်၊ မြေကွက်များ၏ သာယာလှပမှုကို ပြောင်းလဲရန်အတွက် ggthemes စာကြည့်တိုက်မှ ကြိုတင်သတ်မှတ်ထားသော အပြင်အဆင်များကို အသုံးပြုနိုင်ပါသည်။
ဦးစွာ၊ ကျွန်ုပ်တို့သည် ggthemes ဒစ်ဂျစ်တိုက်ကို တင်ပါမည်-
library(ggthemes)
ထို့နောက် မြေကွက်များ၏ အလှတရားကို မွမ်းမံပြင်ဆင်ရန် ကြိုတင်သတ်မှတ်ထားသော အပြင်အဆင်များကို အသုံးပြုခြင်း၏ နမူနာအချို့ကို ပြသပါမည်။
theme_wsj
Wall Street Journal မှ ဆောင်ပုဒ်တစ်ခု။
ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width, color = Species)) +
geom_point() +
theme_wsj()
theme_tufte
စာရင်းအင်းပညာရှင် Edward Tufte ၏လက်ရာဖြင့် မှုတ်သွင်းထားသော ရိုးရှင်းသော အပြင်အဆင်။
ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width, color = Species)) +
geom_point() +
theme_tufte()
solarized_theme
Solarized Palette ကို အခြေခံ၍ အရောင်များကို အသုံးပြုသည့် အပြင်အဆင်။
ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width, color = Species)) +
geom_point() +
theme_solarized()
ကွက်ကွက်ပေါ်တွင် မှောင်သောနောက်ခံကို အသုံးပြုရန် အလင်း = FALSE အငြင်းအခုံကိုလည်း အသုံးပြုနိုင်ကြောင်း သတိပြုပါ။
ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width, color = Species)) +
geom_point() +
theme_solarized( light = FALSE )
theme_gdocs
Google Docs Chart ပါသည့် အပြင်အဆင်သည် ပုံသေဖြစ်သည်။
ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width, color = Species)) +
geom_point() +
theme_gdocs()
ဆောင်ပုဒ်_ငါးဆယ့်ရှစ်
Fifthirtyeight.com ၏ မြေကွက်များမှ လှုံ့ဆော်မှုပေးသည့် ဆောင်ပုဒ်။
ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width, color = Species)) +
geom_point() +
theme_fivethirtyeight()
theme_economist
The Economist မှ မှုတ်သွင်းထားသော အကြောင်းအရာ။
ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width, color = Species)) +
geom_point() +
theme_economist()
မြေကွက်များ၏ သီးခြားအစိတ်အပိုင်းများကို မည်ကဲ့သို့ တည်းဖြတ်မည်နည်း။
ကွက်လပ်အကန့်၏ နောက်ခံအရောင်ကို ပြောင်းလဲရန် theme() နှင့် element_rect() လုပ်ဆောင်ချက်များကို အသုံးပြုနိုင်ပါသည်။
theme(panel.background = element_rect(fill, color, size))
- ဖြည့်စွက်- စတုဂံအတွက် အရောင်ဖြည့်ပါ။
- အရောင်: ဘောင်အရောင်
- အရွယ်အစား- နယ်ခြားအရွယ်အစား
ဇယားကွက်၏ အရွယ်အစားနှင့် အသွင်အပြင်ကို ပြောင်းလဲရန် element_line() လုပ်ဆောင်ချက်ကိုလည်း အသုံးပြုနိုင်သည်။
theme(panel.grid.major = element_line(color, size, linetype), panel.grid.minor = element_line(color, size, linetype))
- အရောင်: ဘောင်အရောင်
- အရွယ်အစား- နယ်ခြားအရွယ်အစား
- မျဉ်းအမျိုးအစား- လိုင်း အမျိုးအစား (“ အလွတ်” , “ အစိုင်အခဲ” , “ ဒက်ရှ်” , “ အစက်များ” , “ အစက်ချ” , “ ဒက်ရှ်” , “ ရှည်ဒက်ရှ်” , “ ဒက်ရှ်နှစ်ခု” )
အောက်ပါကုဒ်သည် ကွက်ကွက်ဘောင်ဘောင်များနှင့် ဇယားကွက်များကို ဖယ်ရှားနည်းကို သရုပ်ပြသည်-
ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width, color = Species)) +
geom_point() +
theme(panel.border = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank())
အောက်ဖော်ပြပါကုဒ်သည် ကွက်ကွက်အကန့်နောက်ခံနှင့် ဇယားကွက်များကို မည်သို့ပြောင်းလဲရမည်ကို သရုပ်ပြသည်-
ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width, color = Species)) + geom_point() + theme( panel.background = element_rect(fill = "powderblue", color = "powderblue", size = 0.5, linetype = "solid"), panel.grid.major = element_line(size = 0.5, linetype = 'solid', color = "white"), panel.grid.minor = element_line(size = 0.25, linetype = 'solid', color = "white") )