Visualizing Data

CIS 241, Dr. Ladd

Why Do We Visualize Data?

xkcd.com/688

Visualization can be exploratory, explanatory, or both!

  • Exploratory viz helps us (the researchers or analysts) understand the data.
  • Explanatory viz helps others (the clients or audience) understand our analysis.
  • Many visualizations do both of these things at once!

Some Good Resources on Visualization

What Does Visualization Help Us to See?

Viz Can Help Us See Amounts.

Graph a single value across one set of categories.
  • Variable types: 1 categorical and 1 numerical
  • Common graph types: Bar plot (Don’t confuse the dot plot with the scatter plot!)

Plot Amounts With Multiple Categories.

  • Variable types: 2 or more categorical, 1 numerical
  • Common graph types: Grouped or stacked bar, heat map

Viz Can Help Us See Distributions.

Graph a distribution of a single variable.
  • Variable type: 1 continuous (numerical)
  • Common graph types: Histograms, Density plots, Q-Q plots

Distributions with Multiple Categories.

  • Variable types: 1 continuous (numerical), 1 categorical
  • Common graph types: Box plots, Violin plots

You Try It!

Look at the taxis data set. What visualization type would you use to compare the counts of each destination Borough? Which variables would you use, and what kind of variables are they? Jot down your answers.

Viz Can Help Us See Proportions.

  • Variable types: 1 numerical, 1 categorical
  • Common graph types: Pie chart, Bar plot

Viz Can Help Us See Relationships.

  • Variable types: 2 continuous (numerical), (3 in a bubble chart)
  • Common graph types: Scatter plot, Bubble Chart, Hex bins, Density contours

You Try It!

Look at the taxis data again. What visualization type would you use to compare the distribution of tips among different taxi colors? Which variables would you use, and what kind of variables are they? Jot down your answers.

Viz Helps Us See Time, Location, Uncertainty

Confidence bands are an example of visualized uncertainty.

More on these viz types in future lessons!

Make Great Viz with Altair

Altair is declarative.

  • You use the Grammar of Graphics approach to declare the parts of the visualization.
  • Focus on what you want to show rather than how to make it appear.
  • Builds on Vega-Lite, works similarly to ggplot2 and Tableau

You Try It!

Use the Altair Cheatsheet to create a plot comparing the high temperature in Seattle to the wind speed using the seattle_weather DataFrame. Then create the same plot but show color as the type of weather.

If this is hard to read, you might also show the types of weather as separate columns.

You Try It!

Create a plot showing the distribution of precipitation in the seattle_weather dataset. Give the plot a title and labels for both axes. Then show the distributions according to each pickup borough, in different columns. Finally, change the size or number of the bins in each distribution to show more detail (narrower bars).

Hint: you may need to use the Altair User Guide as well as the cheatsheet to accomplish this!

Ugly, Bad, or Wrong

More Examples of Bad Viz

viz.wtf

r/dataisugly