Announcement

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

  • Modifying x-axis in a special way.

    Hello,

    I have the following data:

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input int year float(betaUS_12 lbUS_12 ubUS_12 betaUS_22 lbUS_22 ubUS_22 betaUS_32 lbUS_32 ubUS_32 betaUS_42 lbUS_42 ubUS_42 betaUS_52 lbUS_52 ubUS_52 betaUS_62 lbUS_62 ubUS_62 yearless yearmore yearless2 yearmore2 yearless3 yearmore3)
    2002 .09983394 .033573844 .16609405 .03346668   -.0782483 .14518166    .1440442 -.09716225  .3852507  .01871788 -.006193055  .04362882 -.01356009  -.10368413 .07656394   .03437851 -.08063607  .1493931 2001.9 2002.1 2001.7 2002.3 2001.5 2002.5
    2003 .09587947  .03508311 .15667583 .04269629  -.10030187 .18569446 -.007687444  -.2350187  .2196438 .005635773  -.01961588 .030887427 .006968773  -.05116065  .0650982   .07667919 -.10499287 .25835124 2002.9 2003.1 2002.7 2003.3 2002.5 2003.5
    2004 .12801868  .04293675  .2131006 .09327573  -.09861986 .28517133  -.03095711  -.3367621 .27484787 .030958155 -.006891317 .068807624  .15697625  -.16389082  .4778433   .07285965 -.16559835 .31131765 2003.9 2004.1 2003.7 2004.3 2003.5 2004.5
    2010 .40928245  .14798014  .6705847 .14767922  -.05470616  .3500646   .02916339  -.3582467  .4165735  .15948126  .006206103   .3127564  .10309133  -.11584966  .3220323   .14803578 -.07727965  .3733512 2009.9 2010.1 2009.7 2010.3 2009.5 2010.5
    2011  .4288521  .14639796  .7113062 .14513692  -.06522388  .3554977  -.06599972  -.4566956  .3246962  .17356624 -.029254103  .37638655  .09165595   -.0934796  .2767915   .04991825  -.1935455   .293382 2010.9 2011.1 2010.7 2011.3 2010.5 2011.5
    2012 .44900215  .15785253  .7401518 .16681707  -.04752941  .3811635  -.04677118  -.4294767  .3359343   .1860567  -.04058657      .4127  .07954711  -.09387272 .25296694   .04453593  -.2096999  .2987717 2011.9 2012.1 2011.7 2012.3 2011.5 2012.5
    2013  .4477716  .16315645  .7323868  .2167721 -.028667977  .4622122  -.11346623  -.5212641  .2943316   .1766567  -.01163444   .3649478  .10170155 -.069225214  .2726283 -.016602116  -.2701909 .23698667 2012.9 2013.1 2012.7 2013.3 2012.5 2013.5
    2014   .444643  .16338535  .7259007 .23986615 -.002802337 .48253465  -.04892139 -.44388655  .3460438  .13718705  -.02380312   .2981772  .15718333  -.12256058  .4369272  -.01002343 -.25802353 .23797667 2013.9 2014.1 2013.7 2014.3 2013.5 2014.5
    2015  .4561785  .16097455  .7513825  .3165045   .05564618  .5773629   -.1368655  -.5356907  .2619597   .1384413  -.01717886  .29406145  .13912965   -.1395322  .4177915 -.019423565  -.3181144 .27926725 2014.9 2015.1 2014.7 2015.3 2014.5 2015.5
    end


    And im creating the following graph:


    Code:
    * draw graph for exporters
    twoway (scatter betaUS_12 yearless3, msize(small) mcolor(orange_red)) ///
    (rcap ubUS_12 lbUS_12 yearless3, msize(vsmall) lcolor(orange*0.3)) ///
    (scatter betaUS_22 yearless2 , msymbol(square) msize(small) mcolor(green)) ///
    (rcap ubUS_22 lbUS_22 yearless2 , msize(vsmall) lcolor(green*0.3)) ///
    (scatter betaUS_32 yearless, msymbol(triangle) msize(small) mcolor(blue)) ///
    (rcap ubUS_32 lbUS_32 yearless , msize(vsmall) lcolor(blue*0.3)) ///
    (scatter betaUS_42 yearmore  , msymbol(circle) msize(small) mcolor(pink)) ///
    (rcap ubUS_42 lbUS_42 yearmore , msize(vsmall) lcolor(pink*0.3)) ///
    (scatter betaUS_52 yearmore2 , msymbol(square) msize(small) mcolor(purple)) ///
    (rcap ubUS_52 lbUS_52 yearmore2  , msize(vsmall) lcolor(purple*0.3)) ///
    (scatter betaUS_62 yearmore3 , msymbol(diamond) msize(small) mcolor(black)) ///
    (rcap ubUS_62 lbUS_62 yearmore3 , msize(vsmall) lcolor(black*0.3)), ///
    xtitle("") graphregion(color(white)) yline(0, lwidth(medium) lcolor(gs8)) xlabel(2001 2002 2003 2004 2010 2011 2012 2013 2014 2015) ///
    legend(region(lstyle(foreground)) rows(1) position(6) order(1 3 5 7 9 11) label(1 "Japan") label(3 "South Korea") label(5 "Taiwan") label(7 "China") ///
    label(9 "Hong Kong") label(11 "Other")) ///
    ytitle("") ylabel(-0.4(0.2)0.6)
    Is there a way to exclude the missing years on the x-axis such that it is no longer continious. I do not want there to be a space between the 2004 and 2010 label values on the x-axis, this should also give more space for the rest of the data.

    Thanks,
    Jad

  • #2
    You need to create a new x-variable if you do not want the year values to be interpreted literally.

    Code:
    egen time= group(year), label

    Comment


    • #3
      See also https://www.stata.com/support/faqs/g.../scale-breaks/

      Comment

      Working...
      X