+ - 0:00:00
Notes for current slide
Notes for next slide

Neighborhood Analysis

Session 5: Visualizing Data

1 / 22

Why do we visualize our data?

2 / 22
3 / 22

“I got a couple of my best students and put a series of facts into charts: the size and growth of the Negro American group; its division by age and sex; its distribution, education and occupations; its books and periodicals. We made a most interesting set of drawings, limned on pasteboard cards about a yard square and mounted on a number of moveable standards. The details of finishing these 50 or more charts, in colors, with accuracy, was terribly difficult with little money, limited time and not much encouragement.”

4 / 22

5 / 22

How do craft visualizations that tell a story today?

6 / 22




In this week's labs you'll start to learn the grammar of graphics in GGplot

7 / 22




In this week's labs you'll start to learn the grammar of graphics in GGplot


Data: Your source data

Aesthetics: What variables are visualized and how

Geometry: The specific plot type we would like to make

Facets: Facets allow us to create small multiples

Statistics: summaries of data distribution

Coordinates: Coordinate system for the plot

Themes: Collections of plot styles and options

8 / 22

Basic template

  • ggplot: "Initialize" a map object (data frame, aesthetics, columns...)
  • geom: add layers (use the + operator)
  • The + sign used to add new layers must be placed at the end of the line
ggplot(data = <DATA>, mapping = aes(<MAPPINGS>)) + <GEOM_FUNCTION>()
9 / 22

Aesthetics

ggplpt(data = <DATA>, mapping = aes(<mappings)) + <GEOM_FUNCTION>()
Item Description
x Position on x-axis
y Position on y-axis
shape Shape
color Color of border of elements
fill Color of inside of elements (changes the color of the graph by group/facor)
size Size
alpha Transparency (1: opaque; 0: transparent)
line type Type of line (e.g., solid, dashed)
10 / 22

Geometries

ggplpt(data = <DATA>, mapping = aes(<mappings)) + <GEOM_FUNCTION>()
Item Description
geom_point Scatter plots, dot plots, etc.
geom_boxplot Boxplots
geom_line Trend lines, time series, etc.
geom_path Connects the observations in the order in which they appear in the data
geom_histogram Visualise the distribution of a single continuous variable
geom_hline Add horizontal reference lines
geom_vline Add vertical reference lines
geom_smooth Add a smoothing line in order to see what the trends look like
geom_sf Visualize simple feature (sf) objects(maps)
11 / 22

A Tweet sparks a question...

Sorry to bring COVID into this...

What demographic factors help to explain the difference between where people are dying and where vaccinations are occurring?

12 / 22

13 / 22

14 / 22

15 / 22

What's the relationship between COVID cases and vaccinations?

ggplot(dataset %>% filter(percent_tested_positive_cumulative !=0)) +
geom_point(aes(x=percent_tested_positive_cumulative, y=X_1st_dose_percent_population))+
labs(x="Pop. Positive (%)", y="Pop. Vaccinated (%)")+
scale_x_continuous(labels=scales::percent)+
scale_y_continuous(labels=scales::percent)+
theme_minimal()

How would you describe this in your own words?

  • What does each point represent?

  • Are the scales for X and Y reasonable? What do they tell you?

  • Is there a particular region on this plot that might spark questions for further exploration?

  • Are you ready to write an op-ed for the Chicago Tribune or Sun Times (the two major newspapers)?

16 / 22

What's the relationship between COVID deaths and vaccinations?

ggplot(dataset %>% filter(percent_tested_positive_cumulative !=0)) +
geom_point(aes(x=death_rate_cumulative, y=X_1st_dose_percent_population))+
labs(x="Death Rate (per 1,000)", y="Pop. Vaccinated (%)")+
scale_x_continuous(labels=scales::percent)+
scale_y_continuous(labels=scales::percent)+
theme_minimal()

How would you describe this in your own words?

  • What does each point represent?

  • Are the scales for X and Y reasonable? What do they tell you?

  • Is there a particular region on this plot that might spark questions for further exploration?

  • Are you ready to write an op-ed for the Chicago Tribune or Sun Times (the two major newspapers)?

17 / 22

ggplot() +
geom_sf(data=dataset, aes(fill=percent_tested_positive_cumulative))+
scale_fill_continuous(trans = 'reverse')+
geom_sf(data=chi, colour="gray40", fill=NA)+
labs(fill="Pop. Positive (%)")+
theme_minimal()

ggplot() +
geom_sf(data=dataset, aes(fill=X_1st_dose_percent_population))+
scale_fill_continuous(trans = 'reverse')+
geom_sf(data=chi, colour="gray40", fill=NA)+
labs(fill="Pop. Vaccinated (%)")+
theme_minimal()
18 / 22

ggplot() +
geom_sf(data=dataset, aes(fill=death_rate_cumulative))+
scale_fill_continuous(trans = 'reverse')+
geom_sf(data=chi, colour="gray40", fill=NA)+
labs(fill="Pop. Died (%)")+
theme_minimal()

ggplot() +
geom_sf(data=dataset, aes(fill=X_1st_dose_percent_population))+
scale_fill_continuous(trans = 'reverse')+
geom_sf(data=chi, colour="gray40", fill=NA)+
labs(fill="Pop. Vaccinated (%)")+
theme_minimal()
19 / 22

What Next?

What are the types of things you would want to
explore to understand what's going on here?

Where might the information come from?

20 / 22

With Data , Aesthetics, and Geometry, you can make a plot - in this week's lab you'll learn how to start layering plot elements together and take an iterative approach to refining plots.

21 / 22

Thursday's Class

On Thursday, we'll continue working on our manipulation of basic data visualizations

22 / 22

Why do we visualize our data?

2 / 22
Paused

Help

Keyboard shortcuts

, , Pg Up, k Go to previous slide
, , Pg Dn, Space, j Go to next slide
Home Go to first slide
End Go to last slide
Number + Return Go to specific slide
b / m / f Toggle blackout / mirrored / fullscreen mode
c Clone slideshow
p Toggle presenter mode
t Restart the presentation timer
?, h Toggle this help
Esc Back to slideshow