偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

我們分析了復(fù)仇者聯(lián)盟系列所有臺(tái)詞,看看英雄們都愛(ài)說(shuō)什么?沒(méi)有劇透!

大數(shù)據(jù) 數(shù)據(jù)分析
復(fù)仇者系列火遍全球絕非意外,這部作品盡管出現(xiàn)了各種人物,而臺(tái)詞可以說(shuō)是最能塑造人物性格的部分了。因此,文摘菌希望用數(shù)據(jù)分析的方式,看看漫威宇宙的英雄喜歡用的詞匯可視化,并通過(guò)此分析他們的人物特點(diǎn),向這部偉大的作品致敬。

[[263786]]

大數(shù)據(jù)文摘出品

作者:蔣寶尚、魏子敏

《復(fù)仇者聯(lián)盟4》終于上映,這部匯集了10年回憶打造的電影,據(jù)看過(guò)的小伙伴們表示:3小時(shí)劇情,毫無(wú)尿點(diǎn),全程都是經(jīng)典回憶。

忙著工作還沒(méi)來(lái)得及看電影,又超怕被劇透的文摘菌這兩天的狀態(tài)基本是這樣👇

[[263787]]

萬(wàn)般捉急的文摘菌在這周也去重新回憶了一下這個(gè)系列的作品。這部電影是復(fù)仇者系列的終結(jié)作品,能有如此成就,離不開(kāi)《鋼鐵俠》、《美國(guó)隊(duì)長(zhǎng)》,《雷神》、《綠巨人》等獨(dú)立敘事電影為其構(gòu)建的宏大的宇宙觀,也在全球觀眾心里種下同一種英雄情結(jié)。

復(fù)仇者系列火遍全球絕非意外,這部作品盡管出現(xiàn)了各種人物,但是每個(gè)英雄又都被塑造地各具特色,讓人一次就能記住。

而臺(tái)詞可以說(shuō)是最能塑造人物性格的部分了。因此,文摘菌希望用數(shù)據(jù)分析的方式,看看漫威宇宙的英雄喜歡用的詞匯可視化,并通過(guò)此分析他們的人物特點(diǎn),向這部偉大的作品致敬。

本次分析,我們主要使用了R語(yǔ)言進(jìn)行編程,目的是找出最能代表每位英雄的詞匯。數(shù)據(jù)選用了三個(gè)比較有代表性的漫威英雄交叉度極高的劇本,分別是:《復(fù)仇者聯(lián)盟》(就是打洛基的那一部)、《復(fù)仇者聯(lián)盟:奧創(chuàng)紀(jì)元》以及《美國(guó)隊(duì)長(zhǎng):內(nèi)戰(zhàn)》。

上代碼前,先來(lái)看看分析結(jié)果。

1. 美國(guó)隊(duì)長(zhǎng):以你的名字呼喚你-鋼鐵俠!

復(fù)仇者聯(lián)盟

作為聯(lián)盟的老大哥,美國(guó)隊(duì)長(zhǎng)超愛(ài)喊別人的名字。并且我們發(fā)現(xiàn),他口中最經(jīng)常出現(xiàn)的名字就是鋼鐵俠。此外,還經(jīng)常點(diǎn)名的是Sam,和Strucker。

[[263788]]

美國(guó)隊(duì)長(zhǎng)和鋼鐵俠可謂《復(fù)仇者聯(lián)盟》系列中兩大相愛(ài)相殺的主角了。兩人在電影中都是領(lǐng)導(dǎo)級(jí)別的角色,但是兩者的追求卻有很大的差異。在電影《美國(guó)隊(duì)長(zhǎng):內(nèi)戰(zhàn)》中,復(fù)仇者聯(lián)盟團(tuán)隊(duì)徹底分崩離析,分別從屬了美國(guó)隊(duì)長(zhǎng)和鋼鐵俠兩大陣營(yíng)。

一方面美國(guó)隊(duì)長(zhǎng)為了自己的好朋友冬兵戰(zhàn)斗,另一方鋼鐵俠為了維護(hù)世界的秩序和為自己的父母報(bào)仇戰(zhàn)斗。兩者即是好友,又是同級(jí)別的對(duì)手,這或許也就解釋了為什么美國(guó)隊(duì)長(zhǎng)總是叫鋼鐵俠的名字。

2. 黑豹:最喜歡談?wù)?ldquo;中二“話(huà)題的貴族

從分析結(jié)果來(lái)看,黑豹最喜歡說(shuō)的是父親、朋友,國(guó)王等聽(tīng)起來(lái)比較“中二“的詞語(yǔ)。

[[263789]]

黑豹的父親前任黑豹特查卡,瓦坎達(dá)的國(guó)王!守護(hù)者振金,是黑豹的偶像,卻在電影中死于一場(chǎng)陰謀。而黑豹作為瓦坎達(dá)的年輕的王位繼承人,將他父親的遺志作為了追求的夢(mèng)想,守護(hù)著瓦坎達(dá)。國(guó)王身份,追求理想,這就是黑豹喜歡談?wù)撨@類(lèi)貴族話(huà)題的原因。

3. 蜘蛛俠:我還是個(gè)“寶寶“。

[[263790]]

作為全隊(duì)的“小朋友“,蜘蛛俠在復(fù)仇者聯(lián)盟系列電影中的臺(tái)詞一直比較幼齒,他在電影中說(shuō)的最多的是詞是:“嗨”、“呃”、“嗯”。

在這三部電影中,蜘蛛俠只是一個(gè)十幾歲的孩子,在這么多大人物面前如果再不蹦蹦跳跳,那就更沒(méi)有存在感了☺。

4. 浩克和鷹眼:大家都愛(ài)黑寡婦。

通過(guò)可視化分析可以發(fā)現(xiàn),綠巨人和鷹眼都非常喜歡提到黑寡婦。

[[263791]]

浩克喜歡和黑寡婦聊天原因很簡(jiǎn)單,因?yàn)楫?dāng)綠巨人發(fā)狂時(shí),黑寡婦用滿(mǎn)心關(guān)愛(ài)的眼神瞅著他那龐大的身軀,對(duì)他說(shuō)道:“嘿,大塊頭,太陽(yáng)快下山了!”然后慢慢地舉起了手,用她那柔軟的手指,伸向了綠巨人的手臂,輕輕滑了下來(lái)。這時(shí)候浩克就會(huì)平息他那滿(mǎn)腔的怒火!

電影中黑寡婦和鷹眼不是戀人或者情侶,他們的關(guān)系一直戀人未滿(mǎn)、曖昧不清。但是,因?yàn)閮扇嗽趶?fù)仇者聯(lián)盟之前就已經(jīng)發(fā)生了一系列故事。刀光劍影,愛(ài)恨情仇,即是老友又是戰(zhàn)友,或許兩人早已暗生情愫。

5. 幻世和緋紅女巫:惺惺相惜,在線(xiàn)發(fā)糖!

復(fù)仇者聯(lián)盟

從數(shù)據(jù)可視化的結(jié)果中可以看到,幻視和緋紅女巫絕對(duì)是soulmate了,兩人的談?wù)搩?nèi)容都很一致,特別喜歡說(shuō)“恐懼、擔(dān)憂(yōu)“類(lèi)話(huà)題!

關(guān)于緋紅女巫,我們可以從她童年的經(jīng)歷和非人的待遇中找到原因。而幻世作為超級(jí)人工智能,能夠看到別的英雄看不到的“畫(huà)面”,可能對(duì)未來(lái)的擔(dān)憂(yōu)讓他心煩意亂。

6. 托爾:能力越大,責(zé)任越大,考慮深遠(yuǎn)

復(fù)仇者聯(lián)盟

托爾作為雷神,擁有多種魔法能力,例如:操控風(fēng)暴,釋放或控制閃電,將閃電能量實(shí)體化為盔甲,瞬間改變天氣,利用雷神之錘飛行,召喚雷神之錘令其飛回托爾用閃電與敵人交戰(zhàn)。

[[263792]]

雷神除去強(qiáng)大的戰(zhàn)斗力,托爾還掌握著星際級(jí)的知識(shí)。例如:寶石知識(shí)、各式星際飛船駕駛技術(shù)、格魯特語(yǔ)(格魯特所在種族的語(yǔ)言)、蟲(chóng)洞知識(shí)。

或許是能力越大,責(zé)任越大,他比其他英雄角色看的更遠(yuǎn)。在電影中,他對(duì)推動(dòng)劇情前進(jìn)的物品更加專(zhuān)注,例如洛基的權(quán)杖以及心靈寶石。

7. 洛基:追逐權(quán)力。

[[263793]]

洛基從小和雷神托爾一起長(zhǎng)大。一直窺視眾神之王的寶座且不認(rèn)同雷神托爾會(huì)是一位合格的繼承人。他野心十足想當(dāng)老大,陰險(xiǎn)狡詐陷害兄長(zhǎng)、反逆父母,視天下生命如草芥,為了目的不擇手段。

總之一句話(huà),他非常想要權(quán)力!

8. 奧創(chuàng):更愛(ài)“詩(shī)和遠(yuǎn)方“。

復(fù)仇者聯(lián)盟

奧創(chuàng)被制造出來(lái)的目的是為了守護(hù)和平,但是一誕生就發(fā)生錯(cuò)誤,認(rèn)為想要和平就要消滅人類(lèi)和復(fù)仇者聯(lián)盟,于是搶走洛基權(quán)杖(心靈寶石)從尤利西斯·克勞手中弄到大量的振金,操縱趙海倫利用再生搖籃幫其制造幻視身體,想要進(jìn)化得更強(qiáng)。

換句話(huà)說(shuō),奧創(chuàng)一出生就被訂上了守護(hù)和平的烙印,雖然他看問(wèn)題的角度不同,但是和復(fù)仇者聯(lián)盟有著共同的任務(wù)。所以,它更加向往詩(shī)與遠(yuǎn)方!

復(fù)仇者聯(lián)盟

上面條條的長(zhǎng)度對(duì)應(yīng)的是超級(jí)英雄使用每個(gè)詞匯的程度。

可視化過(guò)程

最后,分析完全劇的角色,我們也來(lái)一起看看整個(gè)可視化過(guò)程。

導(dǎo)入R語(yǔ)言包:

  1. library(dplyr) 
  2. library(grid) 
  3. library(gridExtra) 
  4. library(ggplot2) 
  5. library(reshape2) 
  6. library(cowplot) 
  7. library(jpeg) 
  8. library(extrafont) 

清除R工作環(huán)境中的全部東西:

  1. rm(list = ls()) 

加載包含所有圖片的文件夾(根據(jù)你自己的情況修改代碼):

  1. dir_images <- "C:\\Users\\Matt\\Documents\\R\\Avengers" 
  2. setwd(dir_images) 

設(shè)置字體:

  1. windowsFonts(Franklin=windowsFont("Franklin Gothic Demi")) 

英雄角色名字的簡(jiǎn)化版本:

  1. character_names <- c("black_panther","black_widow","bucky","captain_america", 
  2.                     "falcon","hawkeye","hulk","iron_man", 
  3.                     "loki","nick_fury","rhodey","scarlet_witch", 
  4.                     "spiderman","thor","ultron","vision") 
  5. image_filenames <- paste0(character_names, ".jpg") 

將所有圖片讀入一個(gè)列表中。

  1. all_images <- lapply(image_filenames, read_image) 

將角色名字分配給圖像列表,以便按名字對(duì)其進(jìn)行索引。

  1. names(all_images) <- character_names 

例如:

  1. # clear the plot window 
  2. grid.newpage() 
  3. # draw to the plot window 
  4. grid.draw(rasterGrob(all_images[['vision']])) 

[[263794]]

獲得文本數(shù)據(jù)

數(shù)據(jù)由計(jì)算機(jī)科學(xué)家Elle O'Brien收集的,使用文本挖掘技術(shù)對(duì)電影劇本分析。

更正專(zhuān)有名稱(chēng)的大寫(xiě):

  1. capitalize <- Vectorize(function(string){ 
  2.   substr(string,1,1) <- toupper(substr(string,1,1)) 
  3.   return(string) 
  4. }) 
  5. proper_noun_list <- c("clint","hydra","steve","tony", 
  6.                       "sam","stark","strucker","nat","natasha", 
  7.                       "hulk","tesseract", "vision", 
  8.                       "loki","avengers","rogers", "cap", "hill") 
  9. # Run the capitalization function 
  10. word_data <- word_data %>
  11.   mutate(word = ifelse(word %in% proper_noun_list, capitalize(word), word)) %>
  12.   mutate(word = ifelse(word == "jarvis", "JARVIS", word)) 

請(qǐng)注意,以前的簡(jiǎn)版角色名字與文本dataframe格式中的角色不匹配。

  1. unique(word_data$Speaker) 
  2. ##  [1] "Black Panther"   "Black Widow"     "Bucky" 
  3. ##  [4] "Captain America" "Falcon"          "Hawkeye" 
  4. ##  [7] "Hulk"            "Iron Man"        "Loki" 
  5. ## [10] "Nick Fury"       "Rhodey"          "Scarlet Witch" 
  6. ## [13] "Spiderman"       "Thor"            "Ultron" 
  7. ## [16] "Vision" 

創(chuàng)建一個(gè)索引表,將文件名轉(zhuǎn)換為角色名。

  1. character_labeler <- c(`black_panther` = "Black Panther", 
  2.                        `black_widow` = "Black Widow", 
  3.                        `bucky` = "Bucky", 
  4.                        `captain_america` = "Captain America", 
  5.                        `falcon` = "Falcon", `hawkeye` = "Hawkeye", 
  6.                        `hulk` = "Hulk", `iron_man` = "Iron Man", 
  7.                        `loki` = "Loki", `nick_fury` = "Nick Fury", 
  8.                        `rhodey` = "Rhodey",`scarlet_witch` ="Scarlet Witch", 
  9.                        `spiderman`="Spiderman", `thor`="Thor", 
  10.                        `ultron` ="Ultron", `vision` ="Vision") 

有兩個(gè)不同版本的角色名,一個(gè)用于顯示(漂亮),一個(gè)用于索引(簡(jiǎn)單)。

  1. convert_pretty_to_simple <- Vectorize(function(pretty_name){ 
  2.   # pretty_name = "Vision" 
  3.   simple_name <- names(character_labeler)[character_labeler==pretty_name] 
  4.   # simple_name <- as.vector(simple_name) 
  5.   return(simple_name) 
  6.  
  7. }) 
  8. # convert_pretty_to_simple(c("Vision","Thor")) 
  9. # just for fun, the inverse of that function 
  10. convert_simple_to_pretty <- function(simple_name){ 
  11.   # simple_name = "vision" 
  12.   pretty_name <- character_labeler[simple_name] %>% as.vector() 
  13.   return(pretty_name) 
  14. # example 
  15. convert_simple_to_pretty(c("vision","black_panther")) 
  1. ## [1] "Vision"        "Black Panther" 

將簡(jiǎn)化的角色名稱(chēng)添加到文本數(shù)據(jù)框架中。

  1. word_data$character <- convert_pretty_to_simple(word_data$Speaker) 

為每個(gè)角色指定主顏色:

  1. character_palette <- c(`black_panther` = "#51473E", 
  2.                        `black_widow` = "#89B9CD", 
  3.                        `bucky` = "#6F7279", 
  4.                        `captain_america` = "#475D6A", 
  5.                        `falcon` = "#863C43", `hawkeye` = "#84707F", 
  6.                        `hulk` = "#5F5F3F", `iron_man` = "#9C2728", 
  7.                        `loki` = "#3D5C25", `nick_fury` = "#838E86", 
  8.                        `rhodey` = "#38454E",`scarlet_witch` ="#620E1B", 
  9.                        `spiderman`="#A23A37", `thor`="#323D41", 
  10.                        `ultron` ="#64727D", `vision` ="#81414F" ) 

繪制條形圖☟

  1. avengers_bar_plot <- word_data %>
  2.   group_by(Speaker) %>
  3.   top_n(5, amount) %>
  4.   ungroup() %>
  5.   mutate(word = reorder(word, amount)) %>
  6.   ggplot(aes(x = wordy = amountfill = character))+ 
  7.   geom_bar(stat = "identity"show.legend = FALSE)+ 
  8.   scale_fill_manual(values = character_palette)+ 
  9.   scale_y_continuous(name ="Log Odds of Word"
  10.                      breaks = c(0,1,2)) + 
  11.   theme(text = element_text(family = "Franklin"), 
  12.         # axis.title.x = element_text(size = rel(1.5)), 
  13.         panel.grid = element_line(colour = NULL), 
  14.         panel.grid.major.y = element_blank(), 
  15.         panel.grid.minor = element_blank(), 
  16.         panel.background = element_rect(fill = "white"
  17.                                     colour = "white"))+ 
  18.   # theme(strip.text.x = element_text(size = rel(1.5)))+ 
  19.   xlab("")+ 
  20.   coord_flip()+ 
  21.   facet_wrap(~Speaker, scales = "free_y"
  22. avengers_bar_plot 

這已經(jīng)非常漂亮了,但是還可以更漂亮。比如人物形象通過(guò)“線(xiàn)條”顯示出來(lái)。具體做法是將透明的條形圖全覆蓋,然后從端點(diǎn)向里繪制白色的條形圖,注意條形圖是能夠遮擋圖片的。

[[263795]]

在數(shù)據(jù)框架中,用達(dá)到總值所需的余數(shù)來(lái)補(bǔ)充數(shù)值,這樣當(dāng)將值和余數(shù)組合在一起時(shí),就會(huì)形成長(zhǎng)度一致的線(xiàn)條組合。

  1. max_amount <- max(word_data$amount) 
  2. word_data$remainder <- (max_amount - word_data$amount) + 0.2 

每個(gè)英雄角色僅提取5個(gè)關(guān)鍵詞。

  1. word_data_top5 <- word_data %>
  2.   group_by(character) %>
  3.   arrange(desc(amount)) %>
  4.   slice(1:5) %>
  5.   ungroup() 

將“amount”和“remaining”的格式進(jìn)行轉(zhuǎn)換:

[[263796]]

確保每個(gè)角色有兩個(gè)長(zhǎng)條;一個(gè)用于顯示amount,另一個(gè)用于選擇結(jié)束位置。

這會(huì)將“amount”和“remaining”折疊成一個(gè)名為“variable”的列,指示它是哪個(gè)值,另一列“value”包含每個(gè)值中的數(shù)字。

  1. word_data_top5_m <- melt(word_data_top5, measure.vars = c("amount","remainder")) 

將這些條形圖放在有序因素中,與在數(shù)據(jù)融合中相反。否則,“amount”和“remainder”將在圖上以相反的順序顯示。

  1. word_data_top5_m$variable2 <- factor(word_data_top5_m$variable, 
  2.  
  3.                                      levels = rev(levels(word_data_top5_m$variable))) 

每個(gè)角色僅僅顯示五個(gè)詞匯

注意角色名稱(chēng)的版本問(wèn)題,例如采用“black_panther”而不是“Black Panther”。

  1. plot_char <- function(character_name){ 
  2.   # example: character_name = "black_panther" 
  3.   # plot details that we might want to fiddle with 
  4.   # thickness of lines between bars 
  1.  bar_outline_size <- 0.5 
  2.   # transparency of lines between bars 
  3.   bar_outline_alpha <- 0.25 
  4.   # 
  5.   # The function takes the simple character name, 
  6.   # but here, we convert it to the pretty name, 
  7.   # because we'll want to use that on the plot. 
  8.   pretty_character_name <- convert_simple_to_pretty(character_name) 
  9.  
  10.   # Get the image for this character, 
  11.   # from the list of all images. 
  12.   temp_image <- all_images[character_name] 
  13.   # Make a data frame for only this character 
  14.   temp_data <- word_data_top5_m %>
  15.     dplyr::filter(character == character_name) %>
  16.     mutate(character = character_name
  17.   # order the words by frequency 
  18.   # First, make an ordered vector of the most common words 
  19.   # for this character 
  20.     ordered_words <- temp_data %>
  21.       mutate(word = as.character(word)) %>
  22.       dplyr::filter(variable == "amount") %>
  23.       arrange(value) %>
  24.       `[[`(., "word") 
  25.  
  26.     # order the words in a factor, 
  27.     # so that they plot in this order, 
  28.     # rather than alphabetical order 
  29.     temp_data$word = factor(temp_data$word, levels = ordered_words
  30.  
  31.   # Get the max value, 
  32.   # so that the image scales out to the end of the longest bar 
  33.   max_value <- max(temp_data$value) 
  34.   fill_colors <- c(`remainder` = "white", `value` = "white") 
  35.   # Make a grid object out of the character's image 
  36.   character_image <- rasterGrob(all_images[[character_name]], 
  37.                                 width = unit(1,"npc"), 
  38.                                 height = unit(1,"npc")) 
  39.  
  40.   # make the plot for this character 
  41.   output_plot <- ggplot(temp_data)+ 
  42.     aes(x = wordy = valuefill = variable2)+ 
  43.     # add image 
  44.     # draw it completely bottom to top (x), 
  45.     # and completely from left to the the maximum log-odds value (y) 
  46.  
  47.     # note that x and y are flipped here, 
  48.     # in prep for the coord_flip() 
  49.     annotation_custom(character_image, 
  50.                       xmin = -Inf, xmax = Infymin = 0ymax = max_value) + 
  51.     geom_bar(stat = "identity"color = alpha("white", bar_outline_alpha), 
  52.              size = bar_outline_sizewidth = 1)+ 
  53.  
  54.     scale_fill_manual(values = fill_colors)+ 
  55.     theme_classic()+ 
  56.     coord_flip(expand = FALSE)+ 
  57.     # use a facet strip, 
  58.     # to serve as a title, but with color 
  59.     facet_grid(. ~ character, labellerlabeller = labeller(character = character_labeler))+ 
  60.     # figure out color swatch for the facet strip fill 
  61.     # using character name to index the color palette 
  62.     # colorNA means there's no outline color. 
  63.     theme(strip.background = element_rect(fill = character_palette[character_name], 
  64.                                           color = NA))+ 
  65.     # other theme elements 
  66.     theme(strip.text.x = element_text(size = rel(1.15), color = "white"), 
  67.           text = element_text(family = "Franklin"), 
  68.           legend.position = "none"
  69.           panel.grid = element_blank(), 
  70.           axis.text.x = element_text(size = rel(0.8)))+ 
  71.     # omit the axis title for the individual plot, 
  72.     # because we'll have one for the entire ensemble 
  73.     theme(axis.title = element_blank()) 
  74.   return(output_plot) 

單個(gè)角色是如何設(shè)置?

  1. sample_plot <- plot_char("black_panther")+ 
  2.   theme(axis.title = element_text())+ 
  3.   # x lab is still declared as y lab 
  4.   # because of coord_flip() 
  5.   ylab(plot_x_axis_text) 
  6. sample_plot 

橫軸為什么這么特殊?因?yàn)殡S著數(shù)值的增加,條形圖會(huì)變得越來(lái)越高,因此需要轉(zhuǎn)換刻度。

如下所示☟

  1. logit2prob <- function(logit){ 
  2.   odds <- exp(logit) 
  3.   prob <- odds / (1 + odds) 
  4.   return(prob) 

…這就是這個(gè)軸的樣子:

  1. logit2prob(seq(0, 2.5, 0.5)) 
  1. ## [1] 0.5000000 0.6224593 0.7310586 0.8175745 0.8807971 0.9241418 

注意該列表中連續(xù)項(xiàng)之間的遞減差異:

  1. diff(logit2prob(seq(0, 2.5, 0.5))) 
  1. ## [1] 0.12245933 0.10859925 0.08651590 0.06322260 0.04334474 

好了,可以進(jìn)行下一項(xiàng)了:探討一些細(xì)節(jié),并把上面設(shè)置的函數(shù)應(yīng)用到所有角色的列表中,并把所有的結(jié)果放入一個(gè)列表中。

  1. all_plots <- lapply(character_names, plot_char) 

從圖片中提取標(biāo)題

  1. get_axis_grob <- function(plot_to_pick, which_axis){ 
  2.   # plot_to_pick <- sample_plot 
  3.   tmp <- ggplot_gtable(ggplot_build(plot_to_pick)) 
  4.   # tmp$grobs 
  5.   # find the grob that looks like 
  6.   # it would be the x axis 
  7.   axis_x_index <- which(sapply(tmp$grobs, function(x){ 
  8.     # for all the grobs, 
  9.     # return the index of the one 
  10.     # where you can find the text 
  11.     # "axis.title.x" or "axis.title.y" 
  12.     # based on input argument `which_axis` 
  13.     grepl(paste0("axis.title.",which_axis), x)} 
  14.   )) 
  15.   axis_grob <- tmp$grobs[[axis_x_index]] 
  16.   return(axis_grob) 

提取軸標(biāo)題:

  1. px_axis_x <- get_axis_grob(sample_plot, "x") 
  2. px_axis_y <- get_axis_grob(sample_plot, "y") 

下面是如何使用提取出來(lái)的坐標(biāo)軸:

  1. grid.newpage() 
  2. grid.draw(px_axis_x) 

  1. # grid.draw(px_axis_y) 

匯總所有的英雄:

  1. big_plot <- arrangeGrob(grobs = all_plots

加入圖注,注意圖和坐標(biāo)軸的比例關(guān)系:

  1. big_plot_w_x_axis_title <- arrangeGrob(big_plot, 
  2.                                        px_axis_x, 
  3.                                        heights = c(10,1)) 
  4. grid.newpage() 
  5. grid.draw(big_plot_w_x_axis_title) 

因?yàn)樵~匯的長(zhǎng)度不同,這些圖表占用的頁(yè)面空間略有不同。

所以,這看起來(lái)有點(diǎn)亂。

一般來(lái)說(shuō),我們使用facet_grid()或facet_wrap()確保在繪圖的過(guò)程中保持整齊和對(duì)齊,這個(gè)項(xiàng)目中不再適用,因?yàn)槊總€(gè)都有自己的自定義背景圖像。

使用Cowplot而不是arrangebrob,讓圖片的軸垂直對(duì)齊:

  1. big_plot_aligned <- cowplot::plot_grid(plotlist = all_plotsalign = 'v'nrow = 4

增加X(jué)軸的標(biāo)題,和之前類(lèi)似,注意網(wǎng)格對(duì)齊:

  1. big_plot_w_x_axis_title_aligned <- arrangeGrob(big_plot_aligned, 
  2.                                                px_axis_x, 
  3.                                                heights = c(10,1)) 

然后,大功告成☟

然后,保存一下!

ggsave(big_plot_w_x_axis_title_aligned, file = "Avengers_Word_Usage.png", width = 12, height = 6.3)

相關(guān)報(bào)道:

  • https://towardsdatascience.com/i-analyzed-marvel-movie-scripts-to-learn-what-each-avenger-says-most-2e5e7b6105bf
  • http://mattwinn.com/Plot_Avengers_data.html

【本文是51CTO專(zhuān)欄機(jī)構(gòu)大數(shù)據(jù)文摘的原創(chuàng)文章,微信公眾號(hào)“大數(shù)據(jù)文摘( id: BigDataDigest)”】

     大數(shù)據(jù)文摘二維碼

戳這里,看該作者更多好文

 

責(zé)任編輯:趙寧寧 來(lái)源: 51CTO專(zhuān)欄
相關(guān)推薦

2015-05-27 17:26:08

2012-05-16 10:33:39

2019-05-16 10:34:17

浪潮商用機(jī)器PowerIBM

2018-05-23 12:34:39

Python網(wǎng)絡(luò)爬蟲(chóng)豆瓣電影

2015-05-15 19:41:16

騰訊云

2019-04-12 09:24:46

Spring Clou服務(wù)注冊(cè)

2025-06-19 09:43:11

2023-12-06 13:45:00

AI模型

2014-06-25 09:11:48

技術(shù)

2019-04-24 09:25:51

安全事故復(fù)聯(lián)

2021-08-16 17:36:16

黑客數(shù)據(jù)泄露網(wǎng)絡(luò)安全

2016-03-01 14:28:36

華為華為中國(guó)合作伙伴大會(huì)

2012-01-16 08:56:17

開(kāi)發(fā)程序員

2023-11-07 08:36:34

JavaScriptJS挑戰(zhàn)

2015-10-28 11:01:56

創(chuàng)業(yè)公司抱團(tuán)生存

2013-01-09 09:38:34

Java 8JDK8新版Java

2013-01-08 14:11:14

JavaJDK8lambda

2022-12-08 08:40:25

大數(shù)據(jù)Hadoop存儲(chǔ)

2019-08-26 09:07:49

iPhone蘋(píng)果秋季發(fā)布會(huì)

2019-03-24 15:01:08

蘋(píng)果發(fā)布會(huì)iPhone
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)