真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

R語(yǔ)言可視化中多系列柱形圖與分面組圖美化技巧有哪些

R語(yǔ)言可視化中多系列柱形圖與分面組圖美化技巧有哪些,很多新手對(duì)此不是很清楚,為了幫助大家解決這個(gè)難題,下面小編將為大家詳細(xì)講解,有這方面需求的人可以來(lái)學(xué)習(xí)下,希望你能有所收獲。

專注于為中小企業(yè)提供網(wǎng)站設(shè)計(jì)、網(wǎng)站建設(shè)服務(wù),電腦端+手機(jī)端+微信端的三站合一,更高效的管理,為中小企業(yè)監(jiān)利免費(fèi)做網(wǎng)站提供優(yōu)質(zhì)的服務(wù)。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動(dòng)了上千企業(yè)的穩(wěn)健成長(zhǎng),幫助中小企業(yè)通過(guò)網(wǎng)站建設(shè)實(shí)現(xiàn)規(guī)模擴(kuò)充和轉(zhuǎn)變。

今天跟大家分享多系列與分面組圖的美化技巧!

昨天講的關(guān)于多序列柱形圖與條形圖美化技巧,其實(shí)還漏掉了一些一點(diǎn)兒。

當(dāng)數(shù)據(jù)序列比較多的時(shí)候,特別是超過(guò)四個(gè)以后,還用堆積柱形圖(條形圖)、或者簇狀柱形圖的話,圖表必然會(huì)因?yàn)橄盗刑喽艿綌D壓或者變形,整體就會(huì)不協(xié)調(diào)、不美觀。

還有g(shù)gplot不支持次坐標(biāo)軸功能,它的作圖思維基本源于塔夫脫的可視化理念,而且作者個(gè)人的審美也接受次坐標(biāo)軸(大牛任性),但是他留給大家解決多序列圖表的方案是——分面組圖~

data<-data.frame(Name = c("蘋果","谷歌","臉書","亞馬遜","騰訊"),Conpany = c("Apple","Google","Facebook","Amozon","Tencent"),Sale2013 = c(5000,3500,2300,2100,3100),Sale2014 = c(5050,3800,2900,2500,3300),Sale2015 = c(5050,3800,2900,2500,3300),Sale2016 = c(5050,3800,2900,2500,3300))

R語(yǔ)言可視化中多系列柱形圖與分面組圖美化技巧有哪些

數(shù)據(jù)重塑(寬轉(zhuǎn)長(zhǎng)):

mydata<-melt(mydata,id.vars="Conpany",variable.name="Year",value.name="Sale")

R語(yǔ)言可視化中多系列柱形圖與分面組圖美化技巧有哪些

作圖函數(shù):

ggplot(mydata,aes(Conpany,Sale,fill=Year))+geom_bar(stat="identity",position="dodge")

R語(yǔ)言可視化中多系列柱形圖與分面組圖美化技巧有哪些

默認(rèn)圖表的配色確實(shí)挺難看的,這里我們使用華爾街日?qǐng)?bào)、經(jīng)濟(jì)學(xué)人的主題、及配色模板。

ggplot(mydata,aes(Conpany,Sale,fill=Year))+geom_bar(stat="identity",position="dodge")+theme_wsj()+scale_fill_wsj("rgby", "")+theme(axis.ticks.length=unit(0.5,'cm'))+guides(fill=guide_legend(title=NULL))+ggtitle("The Financial Performance of Five Giant")+theme(axis.title = element_blank())

R語(yǔ)言可視化中多系列柱形圖與分面組圖美化技巧有哪些

ggplot(mydata,aes(Conpany,Sale,fill=Year))+geom_bar(stat="identity",position="dodge")+theme_economist(base_size=14)+scale_fill_economist()+theme(axis.ticks.length=unit(0.5,'cm'))+guides(fill=guide_legend(title=NULL))+ggtitle("The Financial Performance of Five Giant")+theme(axis.title = element_blank())

R語(yǔ)言可視化中多系列柱形圖與分面組圖美化技巧有哪些

以上是我們使用傳統(tǒng)的方法通過(guò)將顏色映射到不同類別的年度收入變量上,達(dá)到了區(qū)分效果,可是這樣終究不是辦法,五個(gè)序列實(shí)在是有點(diǎn)多,已經(jīng)讓然有點(diǎn)兒眼花繚亂了,如果有8個(gè)序列、10個(gè)序列呢,那又該怎么辦呢~

下面跟大家將其中一種比較有效的解決辦法:通過(guò)分面組圖解決多序列圖表:

橫排分面:

柱形分面(橫排):

ggplot(mydata,aes(Conpany,Sale,fill=Year))+geom_bar(stat="identity",position="dodge")+theme_wsj()+scale_fill_wsj("rgby", "")+theme(axis.ticks.length=unit(0.5,'cm'))+guides(fill=guide_legend(title=NULL))+ggtitle("The Financial Performance of Five Giant")+theme(axis.title = element_blank(),legend.position='none')+ facet_grid(.~Year)

R語(yǔ)言可視化中多系列柱形圖與分面組圖美化技巧有哪些

ggplot(mydata,aes(Conpany,Sale,fill=Year))+geom_bar(stat="identity",position="dodge")+theme_economist(base_size=14)+scale_fill_economist()+theme(axis.ticks.length=unit(0.5,'cm'))+guides(fill=guide_legend(title=NULL))+ggtitle("The Financial Performance of Five Giant")+theme(axis.title = element_blank(),legend.position='none')+ facet_grid(.~Year)

R語(yǔ)言可視化中多系列柱形圖與分面組圖美化技巧有哪些

條形分面(橫排):

ggplot(mydata,aes(Conpany,Sale,fill=Year))+geom_bar(stat="identity",position="dodge")+theme_wsj()+scale_fill_wsj("rgby", "")+theme(axis.ticks.length=unit(0.5,'cm'))+guides(fill=guide_legend(title=NULL))+ggtitle("The Financial Performance of Five Giant")+theme(axis.title = element_blank(),legend.position='none')+ facet_grid(.~Year)+coord_flip()

R語(yǔ)言可視化中多系列柱形圖與分面組圖美化技巧有哪些

ggplot(mydata,aes(Conpany,Sale,fill=Year))+geom_bar(stat="identity",position="dodge")+theme_economist(base_size=14)+scale_fill_economist()+theme(axis.ticks.length=unit(0.5,'cm'))+guides(fill=guide_legend(title=NULL))+ggtitle("The Financial Performance of Five Giant")+theme(axis.title = element_blank(),legend.position='none')+ facet_grid(.~Year)+coord_flip()

R語(yǔ)言可視化中多系列柱形圖與分面組圖美化技巧有哪些

豎排分面:

柱形分面(豎排):

ggplot(mydata,aes(Conpany,Sale,fill=Year))+geom_bar(stat="identity",position="dodge")+theme_wsj()+scale_fill_wsj("rgby", "")+theme(axis.ticks.length=unit(0.5,'cm'))+guides(fill=guide_legend(title=NULL))+ggtitle("The Financial Performance of Five Giant")+theme(axis.title = element_blank(),legend.position='none')+ facet_grid(Year~.)

R語(yǔ)言可視化中多系列柱形圖與分面組圖美化技巧有哪些

ggplot(mydata,aes(Conpany,Sale,fill=Year))+geom_bar(stat="identity",position="dodge")+theme_economist(base_size=14)+scale_fill_economist()+theme(axis.ticks.length=unit(0.5,'cm'))+guides(fill=guide_legend(title=NULL))+ggtitle("The Financial Performance of Five Giant")+theme(axis.title = element_blank(),legend.position='none')+ facet_grid(Year~.)

R語(yǔ)言可視化中多系列柱形圖與分面組圖美化技巧有哪些

條形分面(豎排):

ggplot(mydata,aes(Conpany,Sale,fill=Year))+geom_bar(stat="identity",position="dodge")+theme_wsj()+scale_fill_wsj("rgby", "")+theme(axis.ticks.length=unit(0.5,'cm'))+guides(fill=guide_legend(title=NULL))+ggtitle("The Financial Performance of Five Giant")+theme(axis.title = element_blank(),legend.position='none')+ facet_grid(Year~.)+coord_flip()

R語(yǔ)言可視化中多系列柱形圖與分面組圖美化技巧有哪些

ggplot(mydata,aes(Conpany,Sale,fill=Year))+geom_bar(stat="identity",position="dodge")+theme_economist(base_size=14)+scale_fill_economist()+theme(axis.ticks.length=unit(0.5,'cm'))+guides(fill=guide_legend(title=NULL))+ggtitle("The Financial Performance of Five Giant")+theme(axis.title = element_blank(),legend.position='none')+ facet_grid(Year~.)+coord_flip()

R語(yǔ)言可視化中多系列柱形圖與分面組圖美化技巧有哪些

關(guān)于簇狀、分面圖表數(shù)據(jù)標(biāo)簽問題:

昨天在講解的時(shí)候忘記了圖表數(shù)據(jù)標(biāo)簽這回事兒,而且當(dāng)時(shí)確實(shí)也不太會(huì)處理這塊兒,后來(lái)突然找到了處理方法:

簇狀圖標(biāo)簽數(shù)據(jù)處理:

ggplot(mydata,aes(Conpany,Sale,fill=Year,label =Sale))+geom_bar(stat="identity",position="dodge")+theme_wsj()+scale_fill_wsj("rgby", "")+theme(axis.ticks.length=unit(0.5,'cm'))+guides(fill=guide_legend(title=NULL))+ggtitle("The Financial Performance of Five Giant")+theme(axis.title = element_blank())+geom_text(aes(y = Sale + 0.05), position = position_dodge(0.9), vjust = -0.5)

R語(yǔ)言可視化中多系列柱形圖與分面組圖美化技巧有哪些

橫向分面柱圖數(shù)據(jù)標(biāo)簽問題:

ggplot(mydata,aes(Conpany,Sale,fill=Year,label =Sale))+geom_bar(stat="identity",position="dodge")+theme_wsj()+scale_fill_wsj("rgby", "")+theme(axis.ticks.length=unit(0.5,'cm'))+guides(fill=guide_legend(title=NULL))+ggtitle("The Financial Performance of Five Giant")+theme(axis.title = element_blank(),legend.position='none')+ facet_grid(.~Year)+geom_text(aes(y = Sale + 0.05), position = position_dodge(0.9), vjust = -0.5)

R語(yǔ)言可視化中多系列柱形圖與分面組圖美化技巧有哪些

橫向分面條形圖數(shù)據(jù)標(biāo)簽問題:

ggplot(mydata,aes(Conpany,Sale,fill=Year,label =Sale))+geom_bar(stat="identity",position="dodge")+theme_wsj()+scale_fill_wsj("rgby", "")+theme(axis.ticks.length=unit(0.5,'cm'))+guides(fill=guide_legend(title=NULL))+ggtitle("The Financial Performance of Five Giant")+theme(axis.title = element_blank(),legend.position='none')+ facet_grid(.~Year)+geom_text(aes(y = Sale + 0.05), position = position_dodge(0.9), vjust = -0.5)+coord_flip()

R語(yǔ)言可視化中多系列柱形圖與分面組圖美化技巧有哪些

豎向分面柱形圖數(shù)據(jù)標(biāo)簽問題:

ggplot(mydata,aes(Conpany,Sale,fill=Year,label =Sale))+geom_bar(stat="identity",position="dodge")+theme_wsj()+scale_fill_wsj("rgby", "")+theme(axis.ticks.length=unit(0.5,'cm'))+guides(fill=guide_legend(title=NULL))+ggtitle("The Financial Performance of Five Giant")+theme(axis.title = element_blank(),legend.position='none')+ facet_grid(Year~.)+geom_text(aes(y = Sale + 0.05), position = position_dodge(0.9), vjust = -0.5)

R語(yǔ)言可視化中多系列柱形圖與分面組圖美化技巧有哪些

豎向分面條形圖數(shù)據(jù)標(biāo)簽問題:

ggplot(mydata,aes(Conpany,Sale,fill=Year,label =Sale))+geom_bar(stat="identity",position="dodge")+theme_wsj()+scale_fill_wsj("rgby", "")+theme(axis.ticks.length=unit(0.5,'cm'))+guides(fill=guide_legend(title=NULL))+ggtitle("The Financial Performance of Five Giant")+theme(axis.title = element_blank(),legend.position='none')+ facet_grid(Year~.)+geom_text(aes(y = Sale + 0.05), position = position_dodge(0.9), vjust = -0.5)+coord_flip()

R語(yǔ)言可視化中多系列柱形圖與分面組圖美化技巧有哪些

好了,這樣分面組圖及其標(biāo)簽問題算是列舉清楚了。

看完上述內(nèi)容是否對(duì)您有幫助呢?如果還想對(duì)相關(guān)知識(shí)有進(jìn)一步的了解或閱讀更多相關(guān)文章,請(qǐng)關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝您對(duì)創(chuàng)新互聯(lián)的支持。


文章標(biāo)題:R語(yǔ)言可視化中多系列柱形圖與分面組圖美化技巧有哪些
文章URL:http://weahome.cn/article/pphhjs.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部