Don’t use color if they communicate nothing

A collection of common dataviz caveats by

Colors are one of the main mediums used to convey information in a dataviz. They allow us to highlight groups or variation when used appropriately, but can be confusing or misleading otherwise.

Here is an example showing the quantity of weapons exported by the top 20 largest exporters in 2017 (more info here):

# Libraries

# Load dataset from github
data <- read.table("", header=TRUE, sep=",")

# create random color palette
mycolors <- colors()[sample(1:400, nrow(data))]
# Barplot
data %>%
  filter(! %>%
  arrange(Value) %>%
  tail(20) %>%
  mutate(Country=factor(Country, Country)) %>%
  ggplot( aes(x=Country, y=Value, fill=Country) ) +
    geom_bar(stat="identity") +
    scale_fill_manual( values = mycolors ) +
    coord_flip() +
    theme_ipsum() +
      panel.grid.minor.y = element_blank(),
      panel.grid.major.y = element_blank(),
    ) +
    xlab("") +
    ylab("Weapon quantity (SIPRI trend-indicator value)")