data science: data visualization boot camp comparison ... · information graphics: a comprehensive...

22
Data Science: Data Visualization Boot Camp Comparison Linear Charts Across Time Chuck Cartledge, PhD Chuck Cartledge, PhD Chuck Cartledge, PhD Chuck Cartledge, PhD Chuck Cartledge, PhD Chuck Cartledge, PhD Chuck Cartledge, PhD Chuck Cartledge, PhD Chuck Cartledge, PhD Chuck Cartledge, PhD Chuck Cartledge, PhD Chuck Cartledge, PhD Chuck Cartledge, PhD Chuck Cartledge, PhD Chuck Cartledge, PhD Chuck Cartledge, PhD Chuck Cartledge, PhD Chuck Cartledge, PhD Chuck Cartledge, PhD Chuck Cartledge, PhD Chuck Cartledge, PhD 26 January 2020 26 January 2020 26 January 2020 26 January 2020 26 January 2020 26 January 2020 26 January 2020 26 January 2020 26 January 2020 26 January 2020 26 January 2020 26 January 2020 26 January 2020 26 January 2020 26 January 2020 26 January 2020 26 January 2020 26 January 2020 26 January 2020 26 January 2020 26 January 2020 1/22

Upload: others

Post on 14-Jul-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

  • Data Science: Data Visualization Boot CampComparison

    Linear Charts Across Time

    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/22

  • 2/22

    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/22

    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 [3]

  • 4/22

    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 [2]

  • 5/22

    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

  • 6/22

    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

  • 7/22

    Type Sample data Hands on Q & A Conclusion References Files

    Virginia Taxable Sales (1 of 1)

    “The Center For Economic Policy Studies is

    dedicated to applying economic analysis to the

    design, implementation, and evaluation of public

    policy and to providing a better understanding of

    local and regional economies. We aim to help in-

    form leaders on the facts of our local and regional

    economies so that they can make more informed

    decisions. Our services include policy analysis,

    applied research, economic forecasting, regional

    economic studies.”

    CEPS Staff [1]

    We select the data of interest.https://ceps.coopercenter.org/taxable-sales

    https://ceps.coopercenter.org/taxable-sales

  • 8/22

    Type Sample data Hands on Q & A Conclusion References Files

    The first codes. (1 of 5)

  • 9/22

    Type Sample data Hands on Q & A Conclusion References Files

    The first codes. (2 of 5)

    ## https://www.r-bloggers.com/

    ## choosing-colour-palettes-part-ii-educated-choices/

    ## https://data.library.virginia.edu/setting-up-color-palettes-in-r/

    rm(list=ls())

    library(ggplot2)

    library(reshape)

    library(RColorBrewer)

    saveFileName

  • 10/22

    Type Sample data Hands on Q & A Conclusion References Files

    The first codes. (3 of 5)

    myColors

  • 11/22

    Type Sample data Hands on Q & A Conclusion References Files

    The first codes. (4 of 5)

    y="Millions of dollars",

    caption=paste0("Using data from:https://www.census.gov/",

    "foreign-trade/data/index.html"),

    colour="Financial area"

    ) +

    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, group=variable, color=variable))

    g + geom_line(aes(y=value, group=variable, color=variable)) +

    scale_color_brewer(palette="Paired")

  • 12/22

    Type Sample data Hands on Q & A Conclusion References Files

    The first codes. (5 of 5)

  • 13/22

    Type Sample data Hands on Q & A Conclusion References Files

    The second codes. (1 of 5)

  • 14/22

    Type Sample data Hands on Q & A Conclusion References Files

    The second codes. (2 of 5)

    rm(list=ls())

    library(ggplot2)

    library(reshape)

    library(scales)

    saveFileName

  • 15/22

    Type Sample data Hands on Q & A Conclusion References Files

    The second codes. (3 of 5)

    {

    indices

  • 16/22

    Type Sample data Hands on Q & A Conclusion References Files

    The second codes. (4 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)) +

    scale_y_continuous(label=comma)

    g + geom_line(aes(y=value))

    index

  • 17/22

    Type Sample data Hands on Q & A Conclusion References Files

    The second codes. (5 of 5)

    mapping=aes(x=2017, y=Year_2017/1000000),

    label=data$Locality[index],

    color="blue",

    nudge_x=-1.5,

    nudge_y=500

    )

  • 18/22

    Type Sample data Hands on Q & A Conclusion References Files

    Hands-on exercises

    1 In the first set of slides, your supervisor wants just onechange.

    1 Remove the legend, and attach the data type to the end oftheir respective curve.

    2 In the second set of slides:1 One county stands out above all the rest, but there may be

    additional interesting things happening in the mess at thebottom. Expand the mess, identify those cities/counties whosetaxable sales went to 0.00, and why.

  • 19/22

    Type Sample data Hands on Q & A Conclusion References Files

    Q & A time.

    Q: How many supply-siders doesit take to change a light bulb?A: None. The darkness will causethe light bulb to change by itself.

  • 20/22

    Type Sample data Hands on Q & A Conclusion References Files

    What have we covered?

    Line charts with many 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 and mostabused type of graph

    Next: 3D charts.

  • 21/22

    Type Sample data Hands on Q & A Conclusion References Files

    References (1 of 1)

    [1] CEPS Staff, CENTER FOR ECONOMIC POLICY STUDIES,https://ceps.coopercenter.org, 2018.

    [2] Fed. Res. Bank Staff,About Economic Research at the St. Louis Fed,https://research.stlouisfed.org/about.html, 2018.

    [3] Robert L. Harris,Information Graphics: A Comprehensive Illustrated Reference,Oxford University Press, 2000.

    https://ceps.coopercenter.orghttps://research.stlouisfed.org/about.html

  • 22/22

    Type Sample data Hands on Q & A Conclusion References Files

    Files of interest

    1 Code snippet to createimages in this presentation

    2 Extract Federal Reserve

    economic data

    3 Extract Virginia Taxable

    Sales data

    ## First codes## https://www.r-bloggers.com/## choosing-colour-palettes-part-ii-educated-choices/## https://data.library.virginia.edu/setting-up-color-palettes-in-r/rm(list=ls())

    library(ggplot2)library(reshape)library(RColorBrewer)

    saveFileName