Before making your figures, choose one palette you think works well for categorical data and one that works well for ordered or numeric data.
Task 1
Use paletteer to explore palettes and answer the following:
we use qualitative palettes for categrical data, sequential palettes for sequential data, and diverging palettes when data is split about a midline.
#install.packages("paletteer")
library(paletteer)
library(dplyr)
library(scales)
#View(palettes_c_names)
# categorical palette
paletteer_d("RColorBrewer::Set2", n = 6) %>% show_col()
library(paletteer)
library(dplyr)
library(scales)
# numeric palette
paletteer_c("viridis::plasma", n = 6) %>% show_col()
The RColorBrewer::Set2 palette works well for
categorical data because each color is visually different enough to not
confuse the viewer, making it easy to differentiate between groups. The
viridis::plasma palette is good for numeric data because it
provides a smooth gradient of colors that blend together well.
Requirements
Color choice is important in graphics because it directly effects how easily viewers can interpret visual data.
Create a bubble map in ggplot.
Requirements
Acceptable options
Suggested skills
library(ggplot2)
library(dplyr)
# bubble plot
map_data <- tibble(
location = c("one", "two", "three", "four", "five"),
lat = c(40.71, 29.76, 34.05, 41.87, 25.76),
long = c(-74.00, -95.36, -118.24, -87.62, -80.19),
value = c(8.8, 2.3, 3.9, 2.7, 0.5)
)
head(map_data)
## # A tibble: 5 × 4
## location lat long value
## <chr> <dbl> <dbl> <dbl>
## 1 one 40.7 -74 8.8
## 2 two 29.8 -95.4 2.3
## 3 three 34.0 -118. 3.9
## 4 four 41.9 -87.6 2.7
## 5 five 25.8 -80.2 0.5
map_data %>%
ggplot(aes(long, lat)) +
geom_point(aes(size = value, colour = value)) +
geom_text(vjust = +1.4, aes(label = location)) +
scale_color_paletteer_c(`"viridis::plasma"`) +
theme_minimal() +
labs(
title = "Bubble Map Test",
x = "Longitude",
y = "Latitude",
size = "Population Size",
colour = "Population Size"
)
Make one variation of your map using icon labels.
Requirements
Examples of what counts
#install.packages("leaflet")
library(leaflet)
library(ggplot2)
library(dplyr)
# bubble plot
map_data <- tibble(
location = c("one", "two", "three", "four", "five"),
lat = c(40.71, 29.76, 34.05, 41.87, 25.76),
long = c(-74.00, -95.36, -118.24, -87.62, -80.19),
value = c(8.8, 2.3, 3.9, 2.7, 0.5)
)
head(map_data)
## # A tibble: 5 × 4
## location lat long value
## <chr> <dbl> <dbl> <dbl>
## 1 one 40.7 -74 8.8
## 2 two 29.8 -95.4 2.3
## 3 three 34.0 -118. 3.9
## 4 four 41.9 -87.6 2.7
## 5 five 25.8 -80.2 0.5
leaflet(data = map_data) %>%
addTiles() %>%
addCircleMarkers( ~long, ~lat)
using leaflet adds to the visualzation by making the map positions
stand out more because there is an interactive background the viewer can
see instead of a geom_minimal theme.
You may invent a small dataset if needed. Keep it simple.
Example ideas
Build one Sankey diagram.
Requirements
Keep it basic: It does not need to be interactive or highly customized. The goal is to understand the structure.
# install.packages("networkD3")
library(networkD3)
library(dplyr)
# students moving from major to career path
nodes <- data.frame(name = c("Biology", "Math", "Art", "Research", "Tech", "Design"))
links <- data.frame(
source = c(0, 0, 1, 1, 2, 2),
target = c(3, 4, 4, 3, 5, 4),
value = c(15, 5, 20, 10, 25, 5)
)
sankeyNetwork(Links = links,
Nodes = nodes,
Source = "source",
Target = "target",
Value = "value",
NodeID = "name")
Create one hierarchical edge bundling graph. You may use an example dataset from a package, adapt class example code, or create a very small hierarchy yourself.
Build one edge bundling graph.
Requirements
Note:This is meant to be an introduction, not a perfect polished figure. It is okay to rely on a tutorial example and then make small changes.
library(ggraph)
library(igraph)
library(tidyverse)