Data Science: Data Visualization Boot Camp Comparison ...ccartled/Teaching/2020... · Data Science:...
Transcript of Data Science: Data Visualization Boot Camp Comparison ...ccartled/Teaching/2020... · Data Science:...
-
Data Science: Data Visualization Boot CampComparison
Linear Charts
Chuck Cartledge, PhDChuck Cartledge, PhDChuck Cartledge, PhDChuck Cartledge, PhDChuck Cartledge, PhDChuck Cartledge, PhDChuck Cartledge, PhDChuck Cartledge, PhDChuck Cartledge, PhDChuck Cartledge, PhDChuck Cartledge, PhDChuck Cartledge, PhDChuck Cartledge, PhDChuck Cartledge, PhDChuck Cartledge, PhDChuck Cartledge, PhDChuck Cartledge, PhDChuck Cartledge, PhDChuck Cartledge, PhDChuck Cartledge, PhDChuck Cartledge, PhD
26 January 202026 January 202026 January 202026 January 202026 January 202026 January 202026 January 202026 January 202026 January 202026 January 202026 January 202026 January 202026 January 202026 January 202026 January 202026 January 202026 January 202026 January 202026 January 202026 January 202026 January 2020
1/26
-
2/26
Type Sample data Hands on Q & A Conclusion References Files
Table of contents (1 of 1)
1 TypeUsesGeneral considerations
2 Sample data
3 Hands on
4 Q & A
5 Conclusion6 References7 Files
-
3/26
Type Sample data Hands on Q & A Conclusion References Files
A definition
“Sometimes referred to as a curve graph.Line graphs are a family of graphs that dis-play quantitative information by means oflines. They are extremely versatile and there-fore are used extensively. . . . A simple linegraph displays a single data series. It typi-cally has a quantitative scale on the verticalaxis and a category, quantitative, or sequencescale on the horizontal axis.”
R. L. Harris [2]
-
4/26
Type Sample data Hands on Q & A Conclusion References Files
Groundwater Level Monitoring (1 of 2)
“Water table groundwater observation
wells are used to monitor shallow groundwa-
ter responses to drought conditions in each
drought evaluation region. In areas west of
Route I-95, wells completed in shallow frac-
tured rock formations are indicative of wa-
ter table conditions. In the Virginia Coastal
Plain area east of I-95, indicator observa-
tion wells are completed in the shallow un-
confined aquifer. For each observation well,
measured groundwater levels are compared
with historic groundwater level statistics for
the period of record.”
Va. DEQ Staff [3]
We select the sites of interest, using:
-
5/26
Type Sample data Hands on Q & A Conclusion References Files
Groundwater Level Monitoring (2 of 2)
https://www.deq.virginia.gov/Programs/Water/
WaterSupplyWaterQuantity/Drought/
DroughtIndicatorsandRegions/GroundwaterLevels.aspx
https://www.deq.virginia.gov/Programs/Water/WaterSupplyWaterQuantity/Drought/DroughtIndicatorsandRegions/GroundwaterLevels.aspxhttps://www.deq.virginia.gov/Programs/Water/WaterSupplyWaterQuantity/Drought/DroughtIndicatorsandRegions/GroundwaterLevels.aspxhttps://www.deq.virginia.gov/Programs/Water/WaterSupplyWaterQuantity/Drought/DroughtIndicatorsandRegions/GroundwaterLevels.aspx
-
6/26
Type Sample data Hands on Q & A Conclusion References Files
Selecting site of interest
https:
//groundwaterwatch.usgs.
gov/AWLSites.asp?mt=g&S=
363928076332901&ncd=awl
https:
//nwis.waterdata.usgs.gov/
nwis/dv?format=gif_meas&
site_no=363928076332901&
referred_module=gw
https://groundwaterwatch.usgs.gov/AWLSites.asp?mt=g&S=363928076332901&ncd=awlhttps://groundwaterwatch.usgs.gov/AWLSites.asp?mt=g&S=363928076332901&ncd=awlhttps://groundwaterwatch.usgs.gov/AWLSites.asp?mt=g&S=363928076332901&ncd=awlhttps://groundwaterwatch.usgs.gov/AWLSites.asp?mt=g&S=363928076332901&ncd=awlhttps://nwis.waterdata.usgs.gov/nwis/dv?format=gif_meas&site_no=363928076332901&referred_module=gwhttps://nwis.waterdata.usgs.gov/nwis/dv?format=gif_meas&site_no=363928076332901&referred_module=gwhttps://nwis.waterdata.usgs.gov/nwis/dv?format=gif_meas&site_no=363928076332901&referred_module=gwhttps://nwis.waterdata.usgs.gov/nwis/dv?format=gif_meas&site_no=363928076332901&referred_module=gwhttps://nwis.waterdata.usgs.gov/nwis/dv?format=gif_meas&site_no=363928076332901&referred_module=gw
-
7/26
Type Sample data Hands on Q & A Conclusion References Files
The data at last.
We:
1 Identified the sites/wells ofinterest
2 Selected the data type anddates of interest
3 Submitted the request fordata
4 Scrapped the resulting htmlfor the data of interest
All these steps are in theextractWaterLevels.R scriptfile.
Using the URL on the next slide.
-
8/26
Type Sample data Hands on Q & A Conclusion References Files
Sample URL to download data:
https:
//nwis.waterdata.usgs.gov/nwis/dv?cb_72019=on&format=
rdb_meas&site_no=363928076332901&referred_module=gw&
period=&begin_date=1981-01-20&end_date=2018-07-20
363928076332901 is the site identifier, and will change based onthe selected site.
https://nwis.waterdata.usgs.gov/nwis/dv?cb_72019=on&format=rdb_meas&site_no=363928076332901&referred_module=gw&period=&begin_date=1981-01-20&end_date=2018-07-20https://nwis.waterdata.usgs.gov/nwis/dv?cb_72019=on&format=rdb_meas&site_no=363928076332901&referred_module=gw&period=&begin_date=1981-01-20&end_date=2018-07-20https://nwis.waterdata.usgs.gov/nwis/dv?cb_72019=on&format=rdb_meas&site_no=363928076332901&referred_module=gw&period=&begin_date=1981-01-20&end_date=2018-07-20https://nwis.waterdata.usgs.gov/nwis/dv?cb_72019=on&format=rdb_meas&site_no=363928076332901&referred_module=gw&period=&begin_date=1981-01-20&end_date=2018-07-20
-
9/26
Type Sample data Hands on Q & A Conclusion References Files
Federal Reserve Economic Data (1 of 2)
“The Federal Reserve Bank of St. Louis is
the center of the Eighth District of the Federal
Reserve System. . . . The Division monitors the
economic and financial literature and produces
research in the areas of money and banking,
macroeconomics, and international and regional
economics. . . . The Research Division also fur-
nishes its working papers to provide insight into
current Bank interests and developing theories
and to stimulate discussion. . . . The widely used
database FRED is updated regularly and allows
24/7 access to regional and national financial and
economic data.”
Fed. Res. Bank Staff [1]
-
10/26
Type Sample data Hands on Q & A Conclusion References Files
Federal Reserve Economic Data (2 of 2)
We select the data of interest. https://fred.stlouisfed.org
https://fred.stlouisfed.org
-
11/26
Type Sample data Hands on Q & A Conclusion References Files
Selecting data of interest
For manual, singular download: https:
//fred.stlouisfed.org/series/PCE
For programtic, singular download:
https:
//github.com/tidyverse/ggplot2/
blob/master/data-raw/economics.R
We elected to download a series programtically.
https://fred.stlouisfed.org/series/PCEhttps://fred.stlouisfed.org/series/PCEhttps://github.com/tidyverse/ggplot2/blob/master/data-raw/economics.Rhttps://github.com/tidyverse/ggplot2/blob/master/data-raw/economics.Rhttps://github.com/tidyverse/ggplot2/blob/master/data-raw/economics.R
-
12/26
Type Sample data Hands on Q & A Conclusion References Files
The first codes. (1 of 5)
-
13/26
Type Sample data Hands on Q & A Conclusion References Files
The first codes. (2 of 5)
rm(list=ls())
library(ggplot2)
saveFileName
-
14/26
Type Sample data Hands on Q & A Conclusion References Files
The first codes. (3 of 5)
"DroughtIndicatorsandRegions/",
"GroundwaterLevels.aspx"),
colour="Sites of interest"
) +
theme(plot.title=element_text(hjust = 0.5)) +
theme(plot.title=element_text(colour = "blue")) +
theme(plot.subtitle=element_text(hjust = 0.5)) +
theme(plot.subtitle=element_text(colour = "black")) +
theme(plot.caption=element_text(hjust = 0.0)) +
theme(plot.caption=element_text(colour = "red")) +
theme(legend.title.align=0.5) +
theme(axis.text.x=element_text(angle=0, hjust = 0))
g + geom_point()
g + geom_line()
g + geom_line() +
-
15/26
Type Sample data Hands on Q & A Conclusion References Files
The first codes. (4 of 5)
scale_color_manual(
values=c("red", "blue"),
labels=c("Pungo", "Brinkley")
)
xMin
-
16/26
Type Sample data Hands on Q & A Conclusion References Files
The first codes. (5 of 5)
g + geom_line() +
xlim(xMin, xMax) +
scale_color_manual(
values=c("red", "blue"),
labels=c("Pungo", "Brinkley")
) +
scale_x_continuous(name="Dates",
limits=c(xMin, xMax),
breaks=myBreaks,
labels=myLabels) +
theme(axis.text.x=element_text(angle=-45, hjust = 0)) +
theme(legend.position="top")
-
17/26
Type Sample data Hands on Q & A Conclusion References Files
The second codes. (1 of 5)
-
18/26
Type Sample data Hands on Q & A Conclusion References Files
The second codes. (2 of 5)
rm(list=ls())
library(ggplot2)
library(reshape)
saveFileName
-
19/26
Type Sample data Hands on Q & A Conclusion References Files
The second codes. (3 of 5)
) +
theme(plot.title=element_text(hjust = 0.5)) +
theme(plot.title=element_text(colour = "blue")) +
theme(plot.subtitle=element_text(hjust = 0.5)) +
theme(plot.subtitle=element_text(colour = "black")) +
theme(plot.caption=element_text(hjust = 0.0)) +
theme(plot.caption=element_text(colour = "red")) +
theme(legend.title.align=0.5) +
theme(axis.text.x=element_text(angle=0, hjust = 0))
g + geom_line(aes(y=value, color=variable))
data_temp
-
20/26
Type Sample data Hands on Q & A Conclusion References Files
The second codes. (4 of 5)
}
g
-
21/26
Type Sample data Hands on Q & A Conclusion References Files
The second codes. (5 of 5)
theme(axis.text.x=element_text(angle=0, hjust = 0))
g + geom_line(aes(y=percentChange, color=variable))
-
22/26
Type Sample data Hands on Q & A Conclusion References Files
Hands-on exercises
1 In the first set of slides, your supervisor wants number ofchanges:
1 Because there are a lot of data points, and the data is “jaggy”a “smoothing” line might help tell a better story.
2 Change the order of the legend labels to alphabetic, and thecolors to the official colors of Christopher Newport University(http://cnu.edu/ocpr/styleguide/)
2 In the second set of slides:1 Your supervisor wants the labels in the legend to be clearer.2 Your supervisor wants the colors to be red and blue.
http://cnu.edu/ocpr/styleguide/
-
23/26
Type Sample data Hands on Q & A Conclusion References Files
Q & A time.
Q: Why is it that the moreaccuracy you demand from aninterpolation function, the moreexpensive it becomes tocompute?A: That’s the Law of SplineDemand.
-
24/26
Type Sample data Hands on Q & A Conclusion References Files
What have we covered?
Line charts with few items are:
Useful to show qualitative andquantitative changes in the“response” variable.Line attributes (color, width,dash-type) can be used todistinguish one line from another.X and Y axis can be linear ornon-linear
Maybe the most common type ofgraph
Next: Comparing a few categories across a few periods.
-
25/26
Type Sample data Hands on Q & A Conclusion References Files
References (1 of 1)
[1] Fed. Res. Bank Staff,About Economic Research at the St. Louis Fed,https://research.stlouisfed.org/about.html, 2018.
[2] Robert L. Harris,Information Graphics: A Comprehensive Illustrated Reference,Oxford University Press, 2000.
[3] Va. DEQ Staff, Groundwater Level Monitoring,https://www.deq.virginia.gov/Programs/Water/
WaterSupplyWaterQuantity/Drought/
DroughtIndicatorsandRegions/GroundwaterLevels.
aspx, 2018.
https://research.stlouisfed.org/about.htmlhttps://www.deq.virginia.gov/Programs/Water/WaterSupplyWaterQuantity/Drought/DroughtIndicatorsandRegions/GroundwaterLevels.aspxhttps://www.deq.virginia.gov/Programs/Water/WaterSupplyWaterQuantity/Drought/DroughtIndicatorsandRegions/GroundwaterLevels.aspxhttps://www.deq.virginia.gov/Programs/Water/WaterSupplyWaterQuantity/Drought/DroughtIndicatorsandRegions/GroundwaterLevels.aspxhttps://www.deq.virginia.gov/Programs/Water/WaterSupplyWaterQuantity/Drought/DroughtIndicatorsandRegions/GroundwaterLevels.aspx
-
26/26
Type Sample data Hands on Q & A Conclusion References Files
Files of interest
1 Code snippet to createimages in this presentation
2 Extract water levels script
3 Extract Federal Reserve
economic data
## First codesrm(list=ls())
library(ggplot2)
saveFileName