Announcement

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

  • Options to plot yearly data for five years in a single graph

    Hi All.

    I'd like to plot two different graphs using the same data.

    (1) yearly data over five waves in a single graph:
    Code:
    tw (line totasset_ecpc agegrp if wave == 2 & inrange(agegrp, 30, 80))  ///
        (line totasset_ecpc agegrp if wave == 6 & inrange(agegrp, 30, 80))  ///
        (line totasset_ecpc agegrp if wave == 10 & inrange(agegrp, 30, 80))  ///
        (line totasset_ecpc agegrp if wave == 14 & inrange(agegrp, 30, 80))  ///
        (line totasset_ecpc agegrp if wave == 18 & inrange(agegrp, 30, 80)),  ///
    title("Share of Assets - ECPC") name(ecpc, replace) ///
    xla(30(10)80) xtitle("age") ytitle(" Proportion") yla(.3(.1).8) ///
    legend(order(1 "Wave 2" 2 "Wave 6" 3 "Wave 10" 4 "Wave 14" 5 "Wave 18")) ///
    legend(region(lstyle(none)) size(small) col(3) row(1) pos(6) rowgap(1) span)
    (2) combine data for all five waves into a single plot:
    Code:
    tw (scatter totasset_ecpc agegrp if inrange(agegrp, 30, 80)), title("Share of Assets - ECPC (all waves)") ///
    xla(30(10)80) xtitle("age") ytitle(" Share of assets") yla(.3(.1).8) name(ecpcall, replace)
    While trends are observable in each of these graphs, they are cluttered. I'd appreciate options that increase their clarity.
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input byte wave float(totasset_ecpc agegrp)
     2  .7590239 20
     6         . 20
    10  .8799195 20
    14  .2183252 20
    18         . 20
     2  .2032862 25
     6    .44044 25
    10  .4350298 25
    14  .4296866 25
    18  .8124846 25
     2  .5380963 30
     6  .3945256 30
    10  .4283356 30
    14  .5113511 30
    18  .3327902 30
     2  .5441144 35
     6  .4536623 35
    10  .4263607 35
    14   .397131 35
    18 .48152775 35
     2   .531788 40
     6  .6135195 40
    10  .4566517 40
    14 .51987433 40
    18 .39560035 40
     2   .501982 45
     6 .50936675 45
    10  .5787155 45
    14 .53960353 45
    18  .4934241 45
     2  .5184313 50
     6  .4877012 50
    10 .51347977 50
    14   .542489 50
    18 .55537874 50
     2  .5851486 55
     6   .511164 55
    10  .4935571 55
    14  .4886676 55
    18  .5297553 55
     2  .5776826 60
     6  .5293519 60
    10  .5640008 60
    14  .4978073 60
    18  .4536004 60
     2 .55672157 65
     6  .6667274 65
    10  .5255127 65
    14  .5557258 65
    18  .4618697 65
     2  .6269194 70
     6   .532701 70
    10  .5955692 70
    14  .5492495 70
    18 .55500907 70
     2   .505511 75
     6  .6363178 75
    10  .5910302 75
    14  .4802268 75
    18   .542687 75
     2 .27799776 80
     6  .4065089 80
    10  .4931756 80
    14  .6125295 80
    18  .5147132 80
    end
    Stata v.15.1. Using panel data.
    Last edited by Chris Boulis; 28 Apr 2021, 18:35.

  • #2
    you could look at Nick Cox's fabplot, type in Stata ssc desc fabplot
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #3
      https://www.statalist.org/forums/for...e-on-ssc/page3 is perhaps where to start. A paper on front-and-back plots will appear in Stata Journal 21(2).

      Comment


      • #4
        Thank you Maarten Buis. I've installed fabplot and reading Nick's link as I write this. Thanks Nick Cox for the link to subsetplot & fabplot. I read Cox, N.J. 2010. Graphing subsets. Stata Journal 10: 670-681 and found a really nice way to display data by wave using code on pp. 675-676. That said, subsetplot gave close to the same with a lot less code. I also really like fabplot (though is there a way to add age to graphs 2 & 6?).
        Code:
        fabplot line totasset_ecpc agegrp, by(wave) ///
        yti("") xti("") yla(.1(.1).8, ang(h)) xla(20(10)80) legend(off) ///
        front(connect) frontopts(mc(blue) lc(blue)) name(G4, replace)
        I want to observe if there are trends in the data (ratios - proportion of assets of one group compared to another) that is, if data points are clearly higher/lower than 0.5? Finally, is it possible to achieve this on a smaller footprint (a single graph), given the 'spaghetti' problem?

        Click image for larger version

Name:	Gr2.png
Views:	1
Size:	86.7 KB
ID:	1606786

        Click image for larger version

Name:	G4.png
Views:	1
Size:	117.6 KB
ID:	1606785
        Last edited by Chris Boulis; 30 Apr 2021, 03:13.

        Comment

        Working...
        X