Time: 30 minutes
Introduction to visualization, marks, and channels, select and justify a data abstraction to use for a given task, and table data part
![rubric snippet](rubric_img/snip-1q.png)
No. [full credit if label/text identified as a channel and then claim is redundant because have both color and text]
![rubric snippet](rubric_img/snip-1q.png)
This visual encoding would be effective for:
![rubric snippet](rubric_img/snip-1q.png)
This kind of plot could scale up to one or two dozen items [give full credit for any answer from 10 to 50]. It encodes three attributes: population, per-capita pollution, and region name [do not give full credit for four attributes]. It scales to hundreds of levels for the quantiative population and pollution attributes and a dozen or so levels for the categorical locale name attributes. [Since this quiz does not cover the use of color, the full credit given for arguing for more locale levels, students are not expected to discuss the fact that the scalability of categorical color coding is limited to a dozen or so levels.]
Source: https://www.ncsu.edu/labwrite/res/gh/gh-linegraph.html
![rubric snippet](rubric_img/snip-1q.png)
![rubric snippet](rubric_img/snip-1q.png)
None of the attributes are redundantly coded with more than one channel.
![rubric snippet](rubric_img/snip-1q.png)
This visual encoding would be effective for:
![rubric snippet](rubric_img/snip-1q.png)
This plot would be effective for hundreds of key levels, hundreds of value levels.
Review the plot below and answer the questions that follow:
# some set-up code to load libraries and data
import pandas as pd
import matplotlib.pyplot as plt
% matplotlib inline
chopstick = pd.read_csv("http://blog.yhat.com/static/misc/data/chopstick-effectiveness.csv")
chopstick.head()
chop_scatter = chopstick.plot.scatter(x = 'Chopstick.Length', y='Food.Pinching.Effeciency', color = "black" )
plt.xlabel('Chopstick length (mm)')
plt.ylabel('Food pinching efficiency')
chop_scatter.set_ylim(25, 50)
chop_scatter.set_xlim(0, 400)
plt.show(chop_scatter)
![rubric snippet](rubric_img/snip-2q.png)
![rubric snippet](rubric_img/snip-1q.png)
fig_q2 = chopstick.boxplot(column='Food.Pinching.Effeciency', by = 'Chopstick.Length')
plt.xlabel('Chopstick length (mm)')
plt.ylabel('Food pinching efficiency')
plt.title('')
plt.suptitle('')
plt.show(fig_q2)
Review the plot below and answer the questions that follow:
mtcars = pd.read_csv("mtcars.csv")
mtcars.head()
import matplotlib.patches as patches
fig1 = plt.figure()
ax1 = fig1.add_subplot(111)
ax1.set_xlim(25,300)
ax1.set_ylim(0,45)
for i in range(0,mtcars.shape[0]):
ax1.add_patch(
patches.Ellipse(
(mtcars.hp.iloc[i], mtcars.mpg.iloc[i] ), # (x,y) position
mtcars.disp.iloc[i]/10, # width
mtcars.gear.iloc[i]**2, # height
)
)
plt.xlabel("horsepower")
plt.ylabel("miles per gallon")
ax1.annotate('bubble width = diplacement/10', xy=(150, 40),xytext=(150, 40))
ax1.annotate('bubble heigth = $gear^{2}$', xy=(150, 38),xytext=(150, 38))
plt.show(fig1)
![rubric snippet](rubric_img/snip-2q.png)
The horizontal size and vertical size channels are automatically fused into an integrated perception of area. What we directly perceive is the planar size of the circles, namely, their area.
![rubric snippet](rubric_img/snip-1q.png)
Change the channels: Use color to encode gear, and use size to encode displacement.
![rubric snippet](rubric_img/snip-2q.png)
# A one-line solution, which is not perfect.
mtcars.plot.scatter("hp", "mpg", c = mtcars.disp, s = mtcars.gear*50, alpha = 0.8)
# A better solution
fig, ax = plt.subplots()
ax.margins(0.05) # Optional, just adds 5% padding to the autoscaling
color = ['black', 'magenta', 'blue']
i = 0
for name, group in mtcars.groupby('gear'):
ax.scatter(group.hp, group.mpg, s = group.disp, marker = 'o',
label = name, color = color[i], alpha = 0.5)
i += 1
ax.legend(title = "gear", fontsize = 10)
ax.annotate('bubble size = $displacement^2$', xy=(250, 25), xytext=(220, 25))
plt.xlabel("horsepower")
plt.ylabel("miles per gallon")
plt.show(fig)
Which of these visual encodings supports popout? Answer True or False for each:
![rubric snippet](rubric_img/snip-1q.png)
True
![rubric snippet](rubric_img/snip-1q.png)
False
![rubric snippet](rubric_img/snip-1q.png)
True
![rubric snippet](rubric_img/snip-1q.png)
False
![rubric snippet](rubric_img/snip-1q.png)
True
![rubric snippet](rubric_img/snip-1q.png)
False
![rubric snippet](rubric_img/snip-1q.png)
True
![rubric snippet](rubric_img/snip-1q.png)
True