<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          非常驚艷的南丁格爾玫瑰圖

          共 2829字,需瀏覽 6分鐘

           ·

          2021-01-11 18:15


          來源:http://www.practicaldb.com/blog/history-of-data-visualization/


          一、名稱怎么來的

          在克里米亞戰(zhàn)爭(zhēng)期間,南丁格爾發(fā)現(xiàn)戰(zhàn)地醫(yī)院的衛(wèi)生條件惡劣導(dǎo)致很多士兵死亡。因此,她開始研究傷員的死亡和衛(wèi)生環(huán)境的關(guān)系,并試圖用統(tǒng)計(jì)數(shù)據(jù)說服維多利亞女王改善軍事醫(yī)院的衛(wèi)生條件。但是她也擔(dān)心,女王那么忙,沒有時(shí)間看她那厚厚的報(bào)告和那些復(fù)雜的表格數(shù)據(jù)。于是,她設(shè)計(jì)了上面的這個(gè)生動(dòng)又有趣的圖表,巧妙的展示了部隊(duì)醫(yī)院季節(jié)性的死亡率。她自己給它取名叫雞冠花圖(coxcomb)。

          我們先來看看最早的南丁格爾玫瑰圖展示了什么樣的數(shù)據(jù)。這張圖展示的是1854年4月到1855年3月這一年間士兵的死亡情況。其中:

          1)綠色表示死于可預(yù)防疾病的士兵人數(shù);

          2)紅色表示死于槍傷的人數(shù);

          3)黑色表示死于其他意外的人數(shù)。

          從圖中可以看出,在這一年間,死亡人數(shù)最多的并不是在戰(zhàn)爭(zhēng)中受槍傷(紅色部分),大部分的士兵是死于可預(yù)防疾?。ňG色部分),特別是冬天的時(shí)候(1854年11月-1855年2月),死于可預(yù)防疾病的士兵人數(shù)大幅增加。這也反映出醫(yī)院的衛(wèi)生條件、保暖對(duì)于傷員的康復(fù)是多么的重要。因此,才說服了女王大人改善醫(yī)院條件。


          二、玫瑰圖怎么用

          這么有氣質(zhì)的圖表,我們來看看經(jīng)過這么多年的發(fā)展,大家都是怎么用的。盡管外形很像餅圖,但本質(zhì)上來說,南丁格爾玫瑰圖更像在極坐標(biāo)下繪制的柱狀圖或堆疊柱狀圖。只不過,它用半徑來反映數(shù)值(而餅圖是以扇形的弧度來表示數(shù)據(jù)的)。但是,由于半徑和面積之間是平方的關(guān)系,視覺上,南丁格爾玫瑰圖會(huì)將數(shù)據(jù)的比例夸大。因此,當(dāng)我們追求數(shù)據(jù)的準(zhǔn)確性時(shí),玫瑰圖不一定是個(gè)好的選擇。但反過來說,當(dāng)我們需要對(duì)比非常相近的數(shù)值時(shí),適當(dāng)?shù)目浯髸?huì)有助于分辨。

          1. Facebook 和 twitter的用戶對(duì)比

          1)圖表中包括性別、年齡、教育、收入等11個(gè)分類的對(duì)比信息指標(biāo),每個(gè)指標(biāo)占用的圓周的角度相同,即任一指標(biāo)的扇區(qū)角度為(360/11=32.723度)

          2)在“Gender”,“Income”,“Age”,“Education”四個(gè)指標(biāo)中,又被分別劃成幾個(gè)不同的區(qū)段

          來源:http://thenextweb.com/socialmedia/2010/12/20/facebook-vs-twitter-by-the-numbers-infographic/


          2. 披頭士歌曲的音調(diào)

          來源:http://ritholtz.com/2012/02/the-beatles-song-keys/


          3、新冠肺炎全球疫情形勢(shì)



          三、玫瑰圖怎么畫

          案例1:facebook數(shù)據(jù)

          直接使用上面facebook的數(shù)據(jù),關(guān)注公眾號(hào)AI入門學(xué)習(xí)回復(fù)facebook獲取csv文件,用R語(yǔ)言畫個(gè)示例,數(shù)據(jù)格式需要長(zhǎng)格式,如下:

          #facebooks數(shù)據(jù)library(ggplot2)facebook = read.csv("facebook.csv",header=T,stringsAsFactors = FALSE)ggplot(facebook, aes(x = 類別1,y=比例,fill = 類別2)) + geom_bar(alpha = 0.93,stat="identity") + coord_polar()+ theme_bw()+ theme(panel.background = element_rect(fill = "black"))+theme(axis.text = element_blank())+  theme(axis.ticks = element_blank())+# 去掉左上角的刻度線theme(axis.title = element_blank())+  theme(legend.position = 'none')+# 去掉圖例theme(panel.border = element_blank())+# 去掉外層邊框theme(panel.background = element_rect(fill = "black"))+ #黑色背景theme(panel.grid.major.x = element_line(colour = "SpringGreen2", size = 0.3))+ #網(wǎng)格線設(shè)置    theme(panel.grid.major.y = element_line(colour = "SpringGreen2", size = 0.3))+ #網(wǎng)格線設(shè)置  ylim(-0.3,1.1)+scale_fill_discrete(c=1000, l=100)ggsave('rose.png',dpi = 1080)#保存為高清格式,dpi越大越清晰

          圖形如下,可以根據(jù)個(gè)人喜好對(duì)顏色進(jìn)行切換,當(dāng)然,各種標(biāo)注,可以在PPT中完成,多個(gè)對(duì)比的,也可以在PPT中進(jìn)行拼接。


          用R自帶數(shù)據(jù)集畫一個(gè)不帶網(wǎng)格線的

          dsmall?=?diamonds[sample(nrow(diamonds),5000),]ggplot(dsmall, aes(x = clarity,  fill = cut)) + geom_bar(alpha = 0.85) + coord_polar() + theme_bw() + theme(panel.background = element_rect(fill = "black"))+theme(axis.text = element_blank())+  theme(axis.ticks = element_blank())+# 去掉左上角的刻度線theme(axis.title = element_blank())+  theme(legend.position = 'none')+# 去掉圖例theme(panel.border = element_blank())+# 去掉外層邊框theme(panel.background = element_rect(fill = "black"))+ #黑色背景theme(panel.grid=element_blank())+ylim(-50,1000)+scale_fill_manual(values = alpha(c("DarkOrchid1",  "SpringGreen", "Magenta","Cyan","OrangeRed1")))ggsave('rose.png',dpi = 1080)


          案例2:多圖組合

          首先,介紹個(gè)函數(shù),多個(gè)圖組合到一起的

          multiplot <- function(..., plotlist=NULL, file, cols=1, layout=NULL) {      library(grid)      plots <- c(list(...), plotlist)      numPlots = length(plots)      if (is.null(layout)) {        layout <- matrix(seq(1, cols * ceiling(numPlots/cols)),                         ncol = cols, nrow = ceiling(numPlots/cols))??????}
          if (numPlots==1) { print(plots[[1]]) } else { grid.newpage() pushViewport(viewport(layout = grid.layout(nrow(layout), ncol(layout)))) for (i in 1:numPlots) { matchidx <- as.data.frame(which(layout == i, arr.ind = TRUE)) print(plots[[i]], vp = viewport(layout.pos.row = matchidx$row, layout.pos.col = matchidx$col)) } } }


          開始繪圖部分,下六組數(shù)據(jù)替換分別跑一次,得到 p1,p2,p3,p4,p5,p6,然后用上面定義的函數(shù)組合即可

          par(mar=c(0,0,0,0))#c(4,3,8,2,2,1)#c(4,3,5,2,2,10)#c(15,3,5,8,2,8)#c(1,3,5,3,2,8)#c(1,3,9,3,2,3)#c(2,12,9,3,2,3)data = data.frame(value= c(2,12,9,3,2,3), type = c('B','A','C','D','E',F))p1 =ggplot(data, aes(x =type, y=value, fill=type)) + geom_bar(stat = "identity", alpha = 0.99) + coord_polar() + theme_bw() + theme(panel.background = element_rect(fill = "black"))+theme(axis.text = element_blank())+  theme(axis.ticks = element_blank())+# 去掉左上角的刻度線theme(axis.title = element_blank())+  theme(legend.position = 'none')+# 去掉圖例theme(panel.border = element_blank())+# 去掉外層邊框theme(panel.background = element_rect(fill = "black"))+ #黑色背景theme(panel.grid=element_blank())+scale_fill_manual(values = alpha(c("OrangeRed1", 'gray91',"SpringGreen", "Magenta","Cyan", "DarkOrchid1")))multiplot(p1,p2,p3,p4,p5,p6,cols=3)

          結(jié)果如下:

          重新替換一批數(shù)據(jù)得到下圖


          推薦閱讀:

          刷爆網(wǎng)絡(luò)的動(dòng)態(tài)條形圖,3行Python代碼就能搞定

          Python初學(xué)者必須吃透這69個(gè)內(nèi)置函數(shù)!

          Python字典詳解-超級(jí)完整版

          全面理解Python集合,17個(gè)方法全解,看完就夠了

          長(zhǎng)按加群,學(xué)習(xí)交流

          掃描關(guān)注本號(hào)↓

          瀏覽 164
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報(bào)
          評(píng)論
          圖片
          表情
          推薦
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報(bào)
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  AV天堂中文字幕 | 免费小视频 | 一级澡逼A片 | 天天撸天天操天天日 | 中文字幕AⅤ在线 |