In this DV, characters with opposite personalities will be linked together in a chord. The thickness of the chords will represent how much they are different from each other. This blog example will visualize the characters of Avatar the Last Airbender series, and the data first will be prepared as follows.

Data preparation and wrangling

We load the character correlation dataframe and the data of Avatar characters.

load("~/COMM2501 Portfolio - z5218332/files/char_cor_ala.Rda")
load("~/COMM2501 Portfolio - z5218332/files/data_ala.Rda")

We then extract the character names from the full list of the Avatar dataset and rename the column and row names of the correlation dataframe.

library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
character_list_ala <- data_ala %>% select(character_code, fictional_work, character_name) %>% distinct() %>% arrange(character_code) %>% select(character_name)
colnames(char_cor_ala) <- as.character(character_list_ala[,1])
rownames(char_cor_ala) <- as.character(character_list_ala[,1])

As this DV will only visualize characters of opposite personalities, we’ll set those of positive correlations to 0, and change all the negative correlations to positive values for them to act as weights.

char_cor_neg_ala <- char_cor_ala
char_cor_neg_ala[char_cor_neg_ala>0] <- 0
char_cor_neg_ala <- char_cor_neg_ala*-1

Chord diagram DV construction

To construct the chord diagram of opposite character personalities, the chorddiag package will be used.

library(chorddiag)
library(viridis)
## Loading required package: viridisLite
library(widgetframe)
## Loading required package: htmlwidgets
char_opp_chord_ala <- chorddiag(char_cor_neg_ala, showTicks = F, groupnameFontsize = 14, groupnamePadding = 10, margin = 90, palette="YlOrRd", showTooltips = FALSE, showZeroTooltips = FALSE)
## Warning in RColorBrewer::brewer.pal(n, palette): n too large, allowed maximum for palette YlOrRd is 9
## Returning the palette you asked for with that many colors

Visualize the DV:

frameWidget(char_opp_chord_ala)