Announcement

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

  • creating angle at zero

    dear team,
    https://www.thelancet.com/action/sho...2818%2933005-8
    I would like my <5 ipd graph to look exactly like graph A of figure 2 in the above paper.As a result I wish to create my angle at zero.My angle seem to be at -1 of y-axis.
    seem my code and data
    ------------------- copy starting from the next line -----------------------
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input int year byte(agegp ipd nvt vt) int bcd double(bca midyrpop) byte(pneumococcal_pneumonia spnmen) double(vaxera malinc sauinc msmninc adminc time postslope vaxera2017 vacc) float(ipd_inc nvt_inc vt_inc time1)
    1999 11 24  8 16 3490 98.55972889014403              33620  8  8 0  5731.707317073171  32.71861986912552  3869.720404521118 10612.730517549078  1  0 0 0  71.38608  23.79536  47.59072   .5
    2000 11 47 12 35 3482 98.75212705615428              34505  6 10 0  4947.109114621069 20.286914939863788 3616.8671207071434  10404.28923344443  2  0 0 0 136.21214  34.77757 101.43458  1.5
    2001 11 46 14 32 3394 98.49100406268137              35411 15 10 0    4535.3138855158  36.71175623393861  3524.328598458106  9920.646126909716  3  0 0 0 129.90314  39.53574   90.3674  2.5
    2002 11 28  4 24 2286 98.78997407087294              36340 13 10 0 2793.0654925701706 24.766097963676387 2355.5310952118875  6543.753439735828  4  0 0 0  77.05008 11.007154  66.04293  3.5
    2003 11 47  9 38 2634 98.61475102957694              39747 32  8 0 2807.7590761566908 35.222784109492544 2490.7540191712583  6966.563514227489  5  0 0 0 118.24792  22.64322   95.6047  4.5
    2004 11 36 11 25 2524 98.09560823940924              41985 22  5 0  1853.042753364297  26.19983327378826  2348.457782541384  6442.777182327021  6  0 0 0  85.74491 26.199833  59.54507  5.5
    2005 11 31 12 19 2109 97.86542923433875              42738 23  6 0  1104.403575272591 14.039028499227854 1946.7452852262625    5393.3267817867  7  0 0 0  72.53498 28.078056  44.45692  6.5
    2006 11 23  9 14 2269 97.63339070567987              43916 16  2 0  906.2756170871664 29.601967392294377 2037.9816012387284  5587.940613899263  8  0 0 0  52.37271  20.49367  31.87904  7.5
    2007 11 34  8 26 1832 93.27902240325867              44536 18 10 0  523.1722651338243 26.944494341656185 1614.4242859708997  4773.666247530088  9  0 0 0  76.34274 17.962996  58.37974  8.5
    2008 11 19  3 16 1687 92.74326553051127              44820 12  3 0 414.99330655957164 22.311468094600624 1546.1847389558234  4422.132976349843 10  0 0 0  42.39179   6.69344  35.69835  9.5
    2009 11 20  5 15 1879 93.71571072319202              46343 14  1 0 241.67619705241353 38.840817383423605 1706.8381416826705  4598.321213559761 11  0 0 0  43.15646 10.789116 32.367348 10.5
    2010 11 46  7 39 1648 93.63636363636364              47714 33  5 0 417.06836567883636 14.670746531416354 1439.8289810118622   3984.15559374607 12  0 0 0  96.40776 14.670747  81.73701 11.5
    2011 11 16  5 11 1438  95.1058201058201  46961.63835616438  6  1 .  323.6684351751281 19.164578398527322 1218.0154271064032 3443.2359189354083 13  . . . 34.070362 10.646988 23.423374 12.5
    2012 11  7  4  3 1017 92.62295081967213  40730.05464480874  4  1 1 309.35386927122465  17.18632607062359  1013.993238166792  3005.151872920468 14  1 0 1 17.186327  9.820758  7.365568 13.5
    2013 11  4  4  0  805 94.26229508196722 43214.202739726024  2  0 1 217.52107881325674  9.256216119713052  863.1421531632423 2246.9464630603434 15  2 0 1  9.256216  9.256216         0 14.5
    2014 11 10  9  1 1274 94.51038575667656              47807  5  0 1  472.7341184345389 14.642207208149435  983.1196268328906  3068.588282050746 16  3 0 1  20.91744 18.825695  2.091744 15.5
    2015 11  9  7  2 1228 95.04643962848297              47921  6  2 1 396.48588301579684 20.867678053462992 1078.8589553640365 3004.9456396986707 17  4 0 1  18.78091 14.607374  4.173536 16.5
    2016 11  4  3  1 1029 93.63057324840764  42048.96721311475  2  0 1 185.49801616928272  9.512718777911935  972.6754950414954  2903.757406957618 18  5 0 1  9.512719  7.134539 2.3781798 17.5
    2017 11  2  2  0  365  94.0721649484536 18128.926027397258  1  0 1                  0 16.548139671739317  783.2786111289942 2399.4802524022007 19  6 1 2 11.032093 11.032093         0 18.5
    2018 11  6  2  4 1005 90.70397111913357              46210  5  1 1                  0  6.492101276779917  885.0898074009954  2687.729928586886 20  7 1 2 12.984202 4.3280673  8.656135 19.5
    2019 11  6  5  1 1121 88.40694006309148              45972  2  0 1                  0  6.525711302531977  996.2585921865483  3021.404333072305 21  8 1 2 13.051423 10.876185 2.1752372 20.5
    2020 11  2  2  0  788 92.48826291079813              43995  1  1 1                  0   9.09194226616661  706.8985111944539  2202.523013978861 22  9 1 2  4.545971  4.545971         0 21.5
    2021 11  5  4  1  799 92.26327944572749              43446  5  1 1                  0 13.810247203424941  780.2789669935091 2198.1310132118033 23 10 1 2  11.50854  9.206832  2.301708 22.5
    2022 11  4  4  0 1069 90.28716216216216              44409  2  1 1                  0 11.258979035781035  954.7614222342318  2967.866873831881 24 11 1 2  9.007183  9.007183         0 23.5
    end
    label values agegp acat
    label def acat 11 "<5y", modify
    ------------------ copy up to and including the previous line ------------------

    Listed 24 out of 24 observations
    code:


    **<5years
    keep if agegp==11
    gen ipd_inc=(ipd/midyrpop)*100000
    gen nvt_inc=(nvt/midyrpop)*100000
    gen vt_inc=(vt/midyrpop)*100000
    gen time1=time-0.5

    ***put a space of 10 betweeen year using back space to put years between tickmarks
    set scheme s2color
    twoway (scatter ipd_inc time1 if agegp==11, connect(l) mcolor(black) msize(vsmall) xline(12, lpattern(shortdash) lwidth(thin) lcolor(black))) ///
    (scatter nvt_inc time1 if agegp==11,connect(l) mcolor(blue) msize(vsmall) lwidth(thin) lcolor(blue)) ///
    (scatter vt_inc time1 if agegp==11,connect(l) mcolor(red) msize(vsmall) lwidth(thin) lcolor(red)), ///
    graphregion(color(white)) ysc(r(0 150)) ylabel(0(30)150,labsize(vsmall)) xtitle("Years", size(small)) ytitle("Incidence per 100,000", size(small)) ///
    bgcolor(white) xlab(1 "1999 " 2 "2000 " 3 "2001 " 4 "2002 " 5 "2003 " 6 "2004 " ///
    7 "2005 " 8 "2006 " 9 "2007 " 10 "2008 " 11 "2009 " 12 "2010 " 13 "2011 " ///
    14 "2012 " 15 "2013 " 16 "2014 " 17 "2015 " 18 "2016 " 19 "2017 " ///
    20 "2018 " 21 "2019 " 22 "2020 " 23 "2021 " 24 "2022 ", labsize(vsmall)) yscale(titlegap(*6)) xscale(titlegap(*6)) ///
    title("{bf:A <5years}", position(11) size(small)) xsize(9) ysize(5) legend(off)


    regards,
    Fred

  • #2
    Add the highlighted. The years are apparent in the x-axis, get rid of the -xtitle-.

    Code:
    ***put a space of 10 betweeen year using back space to put years between tickmarks
    set scheme s2color
    twoway (scatter ipd_inc time1 if agegp==11, connect(l) mcolor(black) msize(vsmall) xline(12, lpattern(shortdash) lwidth(thin) lcolor(black))) ///
    (scatter nvt_inc time1 if agegp==11,connect(l) mcolor(blue) msize(vsmall) lwidth(thin) lcolor(blue)) ///
    (scatter vt_inc time1 if agegp==11,connect(l) mcolor(red) msize(vsmall) lwidth(thin) lcolor(red)), ///
    graphregion(color(white)) ysc(r(0 150)) ylabel(0(30)150,labsize(vsmall)) xtitle("Years", size(small)) ytitle("Incidence per 100,000", size(small)) ///
    bgcolor(white) xlab(1 "1999 " 2 "2000 " 3 "2001 " 4 "2002 " 5 "2003 " 6 "2004 " ///
    7 "2005 " 8 "2006 " 9 "2007 " 10 "2008 " 11 "2009 " 12 "2010 " 13 "2011 " ///
    14 "2012 " 15 "2013 " 16 "2014 " 17 "2015 " 18 "2016 " 19 "2017 " ///
    20 "2018 " 21 "2019 " 22 "2020 " 23 "2021 " 24 "2022 ", labsize(vsmall)) yscale(titlegap(*6)) xscale(titlegap(*6)) ///
    title("{bf:A <5years}", position(11) size(small)) xsize(9) ysize(5) legend(off) plotregion(margin(zero)) xtitle("")

    Comment


    • #3
      Thanks Andrew.It seem to work but still there is a little problem.
      The x and y axis are now meeting at zero which is great but year 1999 incidence is exactly at xline==0 which is not what I want.
      Regards,
      Fred

      Comment


      • #4
        EDITED: Not sure that the markers and the years coincide. The mismatch is due to your labeling, which you can adjust. Also, you can specify the ticks independently of the axis labels.

        Code:
        ***put a space of 10 betweeen year using back space to put years between tickmarks
        set scheme s2color
        twoway (scatter ipd_inc time1 if agegp==11, connect(l) mcolor(black) msize(vsmall) xline(11.5, lpattern(shortdash) lwidth(thin) lcolor(black))) ///
        (scatter nvt_inc time1 if agegp==11,connect(l) mcolor(blue) msize(vsmall) lwidth(thin) lcolor(blue)) ///
        (scatter vt_inc time1 if agegp==11,connect(l) mcolor(red) msize(vsmall) lwidth(thin) lcolor(red)), ///
        graphregion(color(white)) ysc(r(0 150)) ylabel(0(30)150,labsize(vsmall)) xtitle("Years", size(small)) ytitle("Incidence per 100,000", size(small)) ///
        bgcolor(white) xlab(0.5 "1999 " 1.5 "2000 " 2.5 "2001 " 3.5 "2002 " 4.5 "2003 " 5.5 "2004 " ///
        6.5 "2005 " 7.5 "2006 " 8.5 "2007 " 9.5 "2008 " 10.5 "2009 " 11.5 "2010 " 12.5 "2011 " ///
        13.5 "2012 " 14.5 "2013 " 15.5 "2014 " 16.5 "2015 " 17.5 "2016 " 18.5 "2017 " ///
        19.5 "2018 " 20.5 "2019 " 21.5 "2020 " 22.5 "2021 " 23.5 "2022 ", noticks labsize(vsmall)) yscale(titlegap(*6)) xscale(titlegap(*6)) ///
        title("{bf:A <5years}", position(11) size(small)) xsize(9) ysize(5) legend(off) plotregion(margin(zero)) xtitle("") xtick(0/24)
        Click image for larger version

Name:	Graph.png
Views:	1
Size:	67.7 KB
ID:	1718576

        Last edited by Andrew Musau; 27 Jun 2023, 06:39.

        Comment


        • #5
          Thanks Andrew.You've saved me alot
          Regards,
          Fred Orwa

          Comment


          • #6
            Below is the code I have used with your help and the graph is nice for me now:Thanks Andrew
            keep if agegp==11
            gen ipd_inc=(ipd/midyrpop)*100000
            gen nvt_inc=(nvt/midyrpop)*100000
            gen vt_inc=(vt/midyrpop)*100000
            gen time1=time-0.5

            ***put a space of 10 betweeen year using back space to put years between tickmarks
            set scheme s2color
            twoway (scatter ipd_inc time1 if agegp==11, connect(l) mcolor(black) msize(vsmall) xline(12, lpattern(shortdash) lwidth(thin) lcolor(black))) ///
            (scatter nvt_inc time1 if agegp==11,connect(l) mcolor(blue) msize(vsmall) lwidth(thin) lcolor(blue)) ///
            (scatter vt_inc time1 if agegp==11,connect(l) mcolor(red) msize(vsmall) lwidth(thin) lcolor(red)), ///
            graphregion(color(white)) ysc(r(0 150)) ylabel(0(30)150,labsize(vsmall)) xtitle("Years", size(small)) ytitle("Incidence per 100,000", size(small)) ///
            bgcolor(white) xlab(1 "1999 " 2 "2000 " 3 "2001 " 4 "2002 " 5 "2003 " 6 "2004 " ///
            7 "2005 " 8 "2006 " 9 "2007 " 10 "2008 " 11 "2009 " 12 "2010 " 13 "2011 " ///
            14 "2012 " 15 "2013 " 16 "2014 " 17 "2015 " 18 "2016 " 19 "2017 " ///
            20 "2018 " 21 "2019 " 22 "2020 " 23 "2021 " 24 "2022 ", noticks labsize(vsmall)) yscale(titlegap(*6)) xscale(titlegap(*6)) ///
            title("{bf:A <5years}", position(11) size(small)) xsize(9) ysize(5) legend(off) plotregion(margin(zero)) xtitle("") xtick(0 (1) 24)

            Comment

            Working...
            X