Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Scatterplot help

    I'm looking for advice on how to produce a scatterplot.

    I have data describing two events, A & B, and the year in which each event occurred.

    Unit of observation is US states.

    In some states, both events A & B have occurred; in other states only one or the other event has occurred.

    I want the plot space to reflect observations (i.e. states) where both events have occurred: X-axis is Event A/Year; Y-axis is Event B/Year.

    I also want the plot space to be bisected by a line at a 45 degree angle.

    The bisecting line would reflect event A and event B occurring in the same year.

    Above the bisecting line are observations where event A occurred before event B;
    below the bisecting line are observations where event B occurred before event A

    Furthermore, at the edges of the plot space I want to create lines that plot observations where only one or the other event has occurred.

    A line running along the top of the plot space (parallel to X-axis) would capture states where event B occurred, but not event A;
    a line running along the right edge (parallel to Y-axis) of the plot space would reflect states where event A occurred but not event B.

    I have attached a PDF mock-up of the graph I'm trying to create.

    Thanks in advance for consideration.
    Attached Files

  • #2
    Tim,
    Maybe the following will get you started.

    Code:
    clear
    input yearA yearB
    1980  1980
    1981  1979
    1982  1983
    1984  1984
    1985  1982
    1986  1988
    1987  1987
    1988   .
    .      1978
    end
    replace yearA=1990 if yearA==.
    replace yearB=1990 if yearB==.
    
    scatter yearA yearB, ///
      ylab(1975(5)1990 1990 `" `"Event A"' `"is Missing"' "', angle(0)) ///
      xlab(1975(5)1990 1990 `" `"Event B"' `"is Missing"' "') ///
      ytitle(Year of Event A) xtitle(Year of Event B) ///
      xline(1990, lpattern(dash)) yline(1990, lpattern(dash)) ///
      graphregion(margin(large)) legend(off)  ///
      || function y=x, range(1975 1990)
    Stata/MP 14.1 (64-bit x86-64)
    Revision 19 May 2016
    Win 8.1

    Comment


    • #3
      Thank you! That definitely looks like the graph I'm trying to produce.

      Comment

      Working...
      X