Data Science

Visualizations

Standardized Visuals


# Library 
library(ggplot2)

# Create data set 
df.coins <- data.frame(countries = c("Japan", 
                                     "China", 
                                     "Cuba", 
                                     "Mexico", 
                                     "Venezuela"), 
                       coin_number = c(18, 
                                       29, 
                                       39, 
                                       17, 
                                       14))

# Make countries a factor 
df.coins$countries <- factor(df.coins$countries, 
                             levels = c("Cuba", 
                                        "China", 
                                        "Japan", 
                                        "Mexico", 
                                        "Venezuela"))

# Column plot using only ggplot2
coin.plot <- ggplot2::ggplot(df.coins, 
                             ggplot2::aes(x = countries, 
                                          y = coin_number)) +
  ggplot2::geom_col(fill = "#D0B38F") +
  ggplot2::labs(title = "Number of coins from specific countries",
                x = "Countries",
                y = "Number of coins")

ggplot2::ggsave(coin.plot, 
                filename = "visuals/01-ggplot2-example.png", 
                width = 12,
                height = 9,
                units = "in")
    

# Packages
library(CCMHr)

# Plot
CCMHr::plot_column(data = df.coins,
                   x.var = countries,
                   y.var = coin_number,
                   color = "#D0B38F",
                   save = TRUE,
                   path = "ccmh-basic-example.png",
                   plot.width = 12,
                   plot.height = 9,
                   plot.units = "in",
                   plot.title = "Number of coins from specific countries",
                   x.title = "Countries",
                   y.title = "Number\nof coins")
    

CCMHr::plot_column(data = df.coins,
                   x.var = countries,
                   y.var = coin_number,
                   color = "#D0B38F",
                   save = TRUE,
                   path = "ccmh-advance-example.png",
                   plot.width = 8,
                   plot.height = 6,
                   plot.units = "in",
                   plot.title = "Number of coins from specific countries",
                   x.title = "Countries",
                   y.title = "Number\nof coins", 
                   y.min = 0, # Specify minimum y limit
                   y.max = 40, # Specify maximum y limit
                   y.breaks = seq(0, 40, 10), # Specify breaks for grid lines
                   y.expand = c(0 ,0), # Expand y axis to start at 0
                   column.width = 0.75, # Reduce column width, 
                   y.grid.major = TRUE, # Add major grid lines
                   y.grid.minor = TRUE, # Add minor grid lines
                   y.axis.line = FALSE, # Remove y axis line
                   x.axis.line = FALSE, # Remove x axis line
                   remove.axis.ticks = TRUE, # Remove axis tick marks
                   column.text = TRUE, # Add column text
                   column.text.color = "#292929", # Column text color
                   column.text.position = ggplot2::position_dodge(width = 0.75), # Column text position
                   column.text.vjust = 2, # Column text vertical adjustment
                   column.text.hjust = 0.5) # Column text horizontal adjustment
    

CCMHr::plot_column(data = df.coins,
                   x.var = countries,
                   y.var = coin_number,
                   color = "#D0B38F",
                   save = TRUE,
                   path = "ccmh-plotelements-example.png",
                   plot.width = 8,
                   plot.height = 6,
                   plot.units = "in",
                   plot.title = "Number of coins from specific countries",
                   x.title = "Countries",
                   y.title = "Number\nof coins", 
                   y.min = 0, # Specify minimum y limit
                   y.max = 40, # Specify maximum y limit
                   y.breaks = seq(0, 40, 10), # Specify breaks for grid lines
                   y.expand = c(0 ,0), # Expand y axis to start at 0
                   column.width = 0.75, # Reduce column width, 
                   y.grid.major = TRUE, # Add major grid lines
                   y.grid.minor = TRUE, # Add minor grid lines
                   y.axis.line = FALSE, # Remove y axis line
                   x.axis.line = FALSE, # Remove x axis line
                   remove.axis.ticks = TRUE, # Remove axis tick marks
                   column.text = TRUE, # Add column text
                   column.text.color = "#292929", # Column text color
                   column.text.position = ggplot2::position_dodge(width = 0.75), # Column text position
                   column.text.vjust = 2, # Column text vertical adjustment
                   column.text.hjust = 0.5, # Column text horizontal adjustment
                   plot.element1 = ggplot2::theme(axis.title = ggplot2::element_text(color = "red"))) # Make axis title text color red
    
This graph has no title, but examines changes in the prevalence of different racial/ethnic groups receiving treatment at University/College counseling centers over time. Image from a blog titled "College Counseling Centers are Increasingly Treating a Greater Percentage of Students who Represent Diverse Identities: 11-Year Trends"

Custom Visuals


# Coin Composite example 
  
# Data 
df.composite <- data.frame(composite = c("Silver", 
                                         "Copper", 
                                         "Bronze", 
                                         "Other"), 
                           percent = c(0.5492228, 
                                       0.238342, 
                                       0.119171, 
                                       0.09326425))

# Factor
df.composite$composite <- factor(df.composite$composite, 
                                 levels = rev(c("Silver", 
                                                "Copper", 
                                                "Bronze", 
                                                "Other")))

# Data frames related to creating plot
df.composite.empty <- df.composite |>
  dplyr::mutate(percent = 0)

df.composite2 <- plyr::rbind.fill(df.composite, 
                                  df.composite.empty)

df.line <- df.composite2 |>
  dplyr::mutate(percent = ifelse(percent != 0, 1, 0))

# Plot 
composite.plot <- ggplot2::ggplot(df.composite2, 
                                  ggplot2::aes(x = composite,
                                               y = percent) ) +
  ggplot2::geom_line(data = df.line, 
                     ggplot2::aes(x = composite,
                                  y = percent),
                     lineend = "round", 
                     lwd = 24, 
                     color = "#292929") +
  ggplot2::geom_line(data = df.line, 
                     ggplot2::aes(x = composite,
                                  y = percent),
                     lineend = "round", 
                     lwd = 22, 
                     color = "#fdfdfd") +
  ggplot2::geom_line(color = "#D0B38F", 
                     lineend = "round", 
                     lwd = 19) +
  ggplot2::ylim(-0.025, 1.025) +
  ggplot2::labs(title = "What's My Collection Made Of? A Breakdown by Metal") +
  ggplot2::theme(legend.position = "none",
                 panel.background = ggplot2::element_blank(), 
                 axis.text.x = ggplot2::element_blank(), 
                 axis.title = ggplot2::element_blank(), 
                 plot.title = ggplot2::element_text(hjust = 0.5, 
                                                    face = "bold",
                                                    color = "#292929",
                                                    size = 20),
                 axis.text.y = ggplot2::element_text(family = "sans", 
                                                     face = "bold",
                                                     color = "#292929",
                                                     size = 15),
                 axis.ticks = ggplot2::element_blank()) +
  ggplot2::coord_flip() + 
  ggplot2::geom_text(data = df.composite,
                     ggplot2::aes(label = paste0(format(round(percent, digits = 3)*100, nsmall = 1), "%")), 
                                  hjust = 0.9,
                                  family = "sans",
                                  fontface = "bold",
                                  size = 5, 
                                  color = "#292929")

ggsave(composite.plot, 
       filename = "custom-example.png", 
       width = 9.5,
       height = 6,
       units = "in")
    
We call this a nested column plot. Image from the CCMH 2025 Annual Report's Special Topic titled "Students with Financial Insecurity: Prevalence and Associations with Employment, Extracurricular Activities, and Psychological Distress"

Process Visuals

This is a figure CCMH uses to display the different variables we collect from clients.

Data Art Visuals

Documentation

Static Documents

Dynamic Documents

Scrollytelling

Executive Summaries and Infographics

Other Critical Topics

Data Automation

Larger-Than-Memory Data

Use of Artificial Intelligence (AI)

Skills and Languages I Want to Learn

Scroll to Top