class: center, middle, inverse, title-slide .title[ # Data Visualization ] .subtitle[ ## Chapter 0. Course Description ] .author[ ### Iñaki Úcar ] .institute[ ### Department of Statistics | uc3m-Santander Big Data Institute ] .institute[ ### Master in Computational Social Science ] .date[ ###
Licensed under Creative Commons Attribution
CC BY 4.0
Last generated: 2025-09-06
] --- class: base24 <script type="module"> import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.esm.min.mjs'; </script> # Big Picture .pull-left[ ![:vspace 108]() ### Data Programming - Data reading - Data transformation ⎯⎯⎯⟶ ### Research Design - File organization ⎯⎯⎯⎯⎯⟶ ] .pull-right[ ### Data Visualization - Fundamentals<br>of graphical practice - The grammar of graphs ![:vspace 36]() - Data visualization in R ![:vspace 88]() - Data communication in R ] --- class: base24 # Background and Goals ![:vspace 5]() The learning outcomes of this course are: - Knowledge of the general principles of analytical design, graphical elements and their visual perception. - Ability to select the type of representation and graphic elements most appropriate to the type of data and the result to be communicated. - Ability to read, understand, analyze and elaborate graphic representations with social data. - Ability to produce automated reports and dashboards with reproducible visualizations. The course is **very practical**, with a mix of master classes, discussion and practice. --- class: base24 # Course Contents and Schedule ![:vspace 70]() - **Session 01-03**: Chapter 1. Fundamentals of Graphical Practice - **Session 03-07**: Chapter 2. The Grammar of Graphics - **Session 09-10**: Chapter 3. Data Visualization in R - **Session 08, 11-12**: Chapter 4. Data Communication in R - **Session 13-14**: Discussion and Evaluation <br>![:hspace 117]()⟶ (Dec 10) Student presentations 1 <br>![:hspace 117]()⟶ (Dec 17) Student presentations 2 --- class: base24 # Logistics ![:vspace 50]() ### Slots & Location - **Session 01-14**: Wednesday, 15-18 h, room 2.A.04 <!-- - Nov 08: in a conference, need to reschedule --> <!-- - Nov 15: may need to reschedule too --> <!-- - Dec 06 (holiday) → Jan 10 (Wednesday) --> <!-- - **Session 07-14**: Wednesday, 15--18 h, room 2.A.04 --> <!-- - Nov 02 (exams) → Nov 08 (Tuesday), online? --> <!-- - Nov 09, Dec 07 (holidays) → Jan 10 (Tuesday), Jan 11 (Wednesday) --> ### Resources - **Teaching materials** at https://csslab.uc3m.es/dataviz - We will use [**R**](https://www.r-project.org/) and the [**RStudio**](https://www.rstudio.com/) IDE for all the computational work .center[  ![:hspace 90]()  ] --- class: base24 # Communication and Tutoring ![:vspace 35]() ### (Tentative) Office hours - Monday 15-17 h - Friday 15-17 h - Please, **make an appointment by email** I will primarily communicate with you outside of class and office hours through [Aula Global](https://aulaglobal.uc3m.es) (updates, grades, ...). - You can use **course forum** to ask general questions - You can contact me by e-mail: [inaki.ucar@uc3m.es](mailto:inaki.ucar@uc3m.es) - You may find me at my office: 7.3.J25 (Leganés) --- # Course Assessment ### **25%** Participation + **75%** Final project - **E1. Chart selection**: Select a graph and send it for approval + scope definition - **P1. Chart replication**: Develop R code that replicates the graph step by step - **P2. Chart improvement**: Develop R code that improves or changes the graph - **S1. Report writing**: Write a Rmd article that discusses and shows your code and results - **S2. Presentations**: (*may* be in Rmd) + questions (5 + 5 min. each) - **S3. Feedback**: Pull Request (PR) review and merge <pre class="mermaid" style="zoom:1.1;background:#FAFAFA"> gantt dateFormat YYYY-MM-DD axisFormat %b %d weekday monday tickInterval 2week excludes 2025-12-20, 2025-12-21, 2025-12-22, 2025-12-23, 2025-12-24, 2025-12-25, 2025-12-26, 2025-12-27, 2025-12-28, 2025-12-29, 2025-12-30, 2025-12-31, 2026-01-01, 2026-01-02, 2026-01-03, 2026-01-04, 2026-01-05, 2026-01-06, 2026-01-07 section Exploration E1 :2025-09-08, 8w section Programming P1 :2025-10-20, 6w P2 :2025-11-10, 4w section Submission S1 :2025-11-24, 3w S2 :2025-12-10, 8d PR opened :milestone, v1, 2025-12-15, 1d S3 :2025-12-15, 12d PR merged :milestone, v2, 2026-01-14, 1d </pre> --- class: inverse, center, middle # Final Project Example:<br>Gapminder’s World Health Chart --- class: inverse <iframe src="https://embed.ted.com/talks/lang/en/hans_rosling_the_best_stats_you_ve_ever_seen" style="position:absolute;left:0;top:0;width:100%;height:100%" frameborder="0" scrolling="no"></iframe> --- class: base24 # gapminder.org <iframe src="https://www.gapminder.org/tools/" style="position:absolute;left:0;top:80px;width:100%;height:100%" frameborder="0" scrolling="no"></iframe> --- # Coordinates and Axes: Base Plot ``` r p <- ggplot(filter(gapminder, year == 2007)) + aes(gdpPercap, lifeExp) + ylab("Life expectancy") + xlab("Income") p ``` <img src="ch0_files/figure-html/axes-1.png" width="70%" style="display: block; margin: auto;" /> --- # Coordinates and Axes: Scales and Breaks ``` r breaks <- 500*2^c(0:8) klabel <- scales::label_number(suffix="k", scale=1e-3) labels <- c(breaks[1:5], klabel(breaks[-(1:5)])) p <- p + scale_y_continuous(limits=c(10, 95), breaks=seq(10, 90, 10)) + scale_x_log10(limits=range(breaks), breaks=breaks, labels=labels) p ``` <img src="ch0_files/figure-html/breaks-1.png" width="70%" style="display: block; margin: auto;" /> --- # Theme ``` r p <- p + theme_classic(base_size=16) + theme(panel.grid.major=element_line(), legend.position="none") p ``` <img src="ch0_files/figure-html/theme-1.png" width="70%" style="display: block; margin: auto;" /> --- # Annotations: Year ``` r p <- p + geom_text(aes(8000, 50, label=year), size=65, color="lightgray") p ``` <img src="ch0_files/figure-html/year-1.png" width="70%" style="display: block; margin: auto;" /> --- # Annotations: Income Levels ``` r tlevel <- c(1300, 5000, 14000, 40000) blevel <- c(3000, 8000, 24000) ilevel <- c("INCOME LEVEL 1", "LEVEL 2", "LEVEL 3", "LEVEL 4") p <- p + geom_vline(xintercept=blevel, color="darkgray") + annotate("text", x=tlevel, y=95, color="darkgray", vjust=0, size=3, label=ilevel) + annotate("text", x=blevel, y=95, color="darkgray", vjust=0, size=5, label="◆") p ``` <img src="ch0_files/figure-html/levels-1.png" width="70%" style="display: block; margin: auto;" /> --- # Annotations: Units ``` r p <- p + annotate("text", x=128000, y=10, hjust=0.95, vjust=1, size=3, label="per person (GDP/capita, PPP$ inflation-adjusted") + annotate("text", x=500, y=95, hjust=0.5, vjust=-1.5, size=3, angle=90, label="years") p ``` <img src="ch0_files/figure-html/units-1.png" width="70%" style="display: block; margin: auto;" /> --- # Data: Bubbles ``` r p <- p + geom_point(aes(color=continent, size=pop), alpha=0.7) p ``` <img src="ch0_files/figure-html/bubbles-1.png" width="70%" style="display: block; margin: auto;" /> --- # Data: Adjustments ``` r p <- p + geom_point(aes(size=pop), color="#333333", shape=21) + scale_size_area(max_size=25) p ``` <img src="ch0_files/figure-html/adjustments-1.png" width="70%" style="display: block; margin: auto;" /> --- # Data: Colors ``` r ccolors <- c("#00d5e9", "#7feb00", "#ffe700", "#ff5872") p <- p + scale_color_manual(values=ccolors) p ``` <img src="ch0_files/figure-html/colors-1.png" width="70%" style="display: block; margin: auto;" /> --- # Legend ``` r legend <- ggplot(world) + aes(long, lat, group=group, map_id=region, fill=continent) + geom_map(map=world) + scale_fill_manual(values=ccolors) + theme_void() + theme(legend.position="none") legend ``` <img src="ch0_files/figure-html/legend-1.png" width="70%" style="display: block; margin: auto;" /> --- # Everything Together ``` r ggplot(filter(gapminder, year == 2007)) + # coordinates and axes aes(gdpPercap, lifeExp) + ylab("Life expectancy") + xlab("Income") + scale_y_continuous(limits=c(10, 95), breaks=seq(10, 90, 10)) + scale_x_log10(limits=range(breaks), breaks=breaks, labels=labels) + # theme theme_classic(base_size=16) + theme(panel.grid.major=element_line(), legend.position="none") + # annotations geom_text(aes(8000, 50, label=year), size=65, color="lightgray") + geom_vline(xintercept=blevel, color="darkgray") + annotate("text", x=tlevel, y=95, color="darkgray", vjust=0, size=3, label=ilevel) + annotate("text", x=blevel, y=95, color="darkgray", vjust=0, size=5, label="◆") + annotate("text", x=128000, y=10, hjust=0.95, vjust=1, size=3, label="per person (GDP/capita, PPP$ inflation-adjusted") + annotate("text", x=500, y=95, hjust=0.5, vjust=-1.5, size=3, angle=90, label="years") + # data geom_point(aes(color=continent, size=pop), alpha=0.7) + geom_point(aes(size=pop), color="#333333", shape=21) + scale_size_area(max_size=25) + scale_color_manual(values=ccolors) + # legend annotation_custom(ggplotGrob(legend), xmin=log10(16000), ymin=10, ymax=40) ``` --- # Result <img src="ch0_files/figure-html/result-out-1.png" width="100%" style="display: block; margin: auto;" /> --- # Bonus: Multiple Years <img src="ch0_files/figure-html/facets-1.png" width="100%" style="display: block; margin: auto;" /> --- # Bonus: Dynamic
--- class: inverse, center, middle # (Demo Post)