Visualize Personality of Your Favourite Fictional Character

comic
analysis
Published

December 3, 2022

Introduction

The dataset I have used is from TidyTuesday by courtesy of tanya shapiro

Project collecting and analyzing data from the Open-Source Psychometrics Project. The datasets include information about characters from different universes and their respective personality traits.

About the Open-Source Psychometrics Project (excerpt from website):

This website provides a collection of interactive personality tests with detailed results that can be taken for personal entertainment or to learn more about personality assessment. These tests range from very serious and widely used scientific instruments popular psychology to self produced quizzes. A special focus is given to the strengths, weaknesses and validity of the various systems

Data set includes information on 890 characters total. Information for the entire project can also be downloaded directly from opensychometrics.org. Note, the full zip files are codified — i.e. characters and questions are expressed as varchar IDs and require lookups.

Let’s get started,

Code
p_stat <-  readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2022/2022-08-16/psych_stats.csv')
Rows: 356489 Columns: 10
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (6): char_id, char_name, uni_id, uni_name, question, personality
dbl (4): avg_rating, rank, rating_sd, number_ratings

ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.

There are total 100 tv shows and movies. You can choose your favorite show or a movie. In this post I am analyzing the personality traits of characters from the famous tv show “Friends”.

Filter data for Friends

Code
fri <- p_stat |> 
filter(uni_name == "Friends")
head(fri)
# A tibble: 6 × 10
  char_id char_name     uni_id uni_name question    personality avg_rating  rank
  <chr>   <chr>         <chr>  <chr>    <chr>       <chr>            <dbl> <dbl>
1 F2      Monica Geller F      Friends  messy/neat  neat              95.7     9
2 F2      Monica Geller F      Friends  disorganiz… self-disci…       95.2    27
3 F2      Monica Geller F      Friends  diligent/l… diligent          93.9    87
4 F2      Monica Geller F      Friends  on-time/ta… on-time           93.8    34
5 F2      Monica Geller F      Friends  competitiv… competitive       93.6    56
6 F2      Monica Geller F      Friends  scheduled/… scheduled         93.4    23
# ℹ 2 more variables: rating_sd <dbl>, number_ratings <dbl>

We are focusing on the variables personality and avg_rating. There is total 727 types of personalities. I have chosen the most common ones. Let’s make new tidy data frame.

Code
df1 <- fri |> 
select(-char_id, -uni_id, -uni_name, -question, -rank, -rating_sd, -number_ratings) |> 
filter(personality %in% c("expressive","emotional","opinionated","soft","awkward","bold","dramatic","playful","warm","spontaneous")) |> 
pivot_wider(names_from = personality, values_from = avg_rating,values_fn = list(avg_rating = mean))
head(df1)
# A tibble: 6 × 11
  char_name      opinionated emotional  bold expressive dramatic playful  warm
  <chr>                <dbl>     <dbl> <dbl>      <dbl>    <dbl>   <dbl> <dbl>
1 Monica Geller         81        72.7  71.8       70.0     60.6    64.7  54.2
2 Rachel Green          64.6      85.7  75.3       83.1     78.3    75.9  64.9
3 Chandler Bing         64.9      56.4  59.6       75.7     72.2    80.2  60.6
4 Joey Tribbiani        58        82.4  87.9       86.7     76.9    93.8  85.2
5 Phoebe Buffay         77.5      80.9  88.5       90.8     73.5    91.4  79.4
6 Ross Geller           84.2      66.7  NA         60.6     77.0    NA    53.3
# ℹ 3 more variables: awkward <dbl>, spontaneous <dbl>, soft <dbl>

Now, lets add images to this dataframe and make the data longer again.

Code
df1$image <- c("https://openpsychometrics.org/tests/characters/test-resources/pics/F/2.jpg",
               "https://openpsychometrics.org/tests/characters/test-resources/pics/F/1.jpg",
               "https://openpsychometrics.org/tests/characters/test-resources/pics/F/5.jpg",
               "https://openpsychometrics.org/tests/characters/test-resources/pics/F/4.jpg",
               "https://openpsychometrics.org/tests/characters/test-resources/pics/F/3.jpg",
               "https://openpsychometrics.org/tests/characters/test-resources/pics/F/6.jpg")
Code
d1 <- df1 |> 
  mutate(image = circle_crop(image)) |> 
pivot_longer(cols = c("expressive","emotional","opinionated","soft","awkward","bold","dramatic","playful","warm","spontaneous"),
            names_to = 'personality',
            values_to = 'value')

Now the plotting of graph.

Code
p1 <- d1 %>%
ggplot(aes(x=as.factor(personality), y=value,  fill=personality)) +      
geom_bar(stat="identity")+
ylim(-50,100) +
geom_image(mapping=aes(y=-50,x=1,image=image), size=0.25)+
scale_fill_manual(values = met.brewer("Johnson",10))+
coord_curvedpolar()+
facet_wrap(~char_name)+
theme_light()+
theme(panel.background = element_rect(fill="black", color="black")) +
theme(plot.background  = element_rect(fill="black", color="black")) +
theme(panel.border     = element_rect(color="black")) +
theme(strip.background = element_rect(fill="black", color="black"))+
theme(strip.background = element_rect(color="black", fill="#00CDCD", size=1, linetype="solid"))+
theme(strip.text.x = element_text(size = 20, color = "black", family = "Roboto"))+
theme(axis.text.x = element_text(size = 15, color = "white", family = "Roboto"))+
  theme(axis.title.x = element_blank())+
theme(axis.title.y = element_blank())+
theme(axis.text.y  = element_text(size=15, color = "#FFFFFF", family = 'Roboto'))+
theme(plot.title   = element_text(color="#FFFFFF", size=60, face = "bold", hjust = 0.5, family = 'Roboto'))+
theme(plot.subtitle = element_text(color="#FFFFFF", size=30,hjust = 0.5, family = 'Roboto', face = "bold"))+
theme(legend.position = "none")+
theme(plot.margin = unit(c(1.5, 0.2, 3, 0.35), "cm"))+  
labs(title = "F.R.I.E.N.D.S",
     subtitle= "Personality Traits Scaled from 0-100")  
p1

Game of Thrones Plot

There are 890 characters. You can visualize your favorite characters.

Happy Visualizing 📊📊