Announcement

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

  • [graph] Specific positions for labels in legend

    Hello all,

    I'm currently trying to create some graphs for a project, but I have come upon a problem with the legend/labels.
    I'm plotting 4 simple "lines" (connected), each with a label (as you can see bellow), but I want the legend to look in a specific manner: I want just one of the labels in the first column (label 1 "Total Wealth Growth") , and the remaining 3 in the second column. Despite trying several times with "holes()" and also fake labels, I cannot get the legend to behave as I want



    HTML Code:
    twoway connected sum_terms term_1 term_2 term_3 year if year >2004, ///
    legend(order( 1 "Total wealth growth" 2 "Rural wealth growth" 3 "Urban wealth growth" 4 "Urbanization" ) pos(1) ring(0) ///
    region(lstyle(none)) ///
    rows(3) cols(2) ) ///
    msymbol(T D S S ) ///
    mc(navy dkgreen maroon cranberry ) ///
    lc(navy dkgreen maroon cranberry ) ///
    lpattern(soliddot longdash dash ) ///
    title("Growth decomposition") ///
    xtitle("Years") ///
    ytitle("{&Delta}Wealth") ///
    graphregion(style(none)) ///
    plotregion(style(none)) ///
    xlabel(2005(2)2014) ///
    ylabel(0(0.2)1.4) ///
    saving(decomposition , replace )

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input float wealth_total double(urban_pop rural_pop total_pop) float(year wealth_rural wealth_urban fraction_urban change_fraction_urban change_wealth_urban change_wealth_rural term_1 term_2 term_3 sum_terms check_based)
    22.799215         105355.723         265661.208 371016.92333984375 2004 14.159863  44.5839 .28396472          .         .        .         .         .         .         0         .
     23.85501 110231.71399999998         270961.071  381192.7978515625 2005 14.844296 46.00429 .28917575 .005211025  1.420391  .684433 .49007815   .403341  .1623755 1.0557947 1.0557957
    24.920116 115348.57400000001         276369.931  391718.5057373047 2006   15.6357 47.16515 .29446802 .005292267 1.1608658 .7914038   .562549  .3356942  .1668623 1.0651054 1.0651054
     26.03555         122364.964         283744.863  406109.8321533203 2007 16.455778 48.40319    .30131 .006842017 1.2380333 .8200779 .57859117  .3645612  .2185847 1.1617371 1.1154308
     27.17939         130568.634 293085.25899999996  423653.8917236328 2008 17.290499 49.64148  .3081965 .006886452 1.2382927 .8347206 .58321095    .37311  .2227835 1.1791044 1.1438427
     28.03657         136766.478         298751.732  435518.2097167969 2009  18.08564 50.02607  .3140316 .005835116 .38459015 .7951412  .5500815 .11852933  .1863761  .8549869  .8571815
     28.89152         143237.864         304469.888  447707.7575683594 2010 18.878685 50.41573  .3199361 .005904466  .3896599  .793045 .54400384 .12236552  .1862094  .8525788  .8549461
     29.79181         149971.719  310250.3460000001 460222.07177734375 2011  19.63157 51.04117  .3258682 .005932093  .6254425 .7528858  .5120105  .2001016 .18632467  .8984368  .9002895
     30.64884 156971.99099999998         316084.609  473056.5930175781 2012 20.358894 51.58923   .331825 .005956799 .54805374 .7273235 .49031195 .17859326  .1860328   .854938  .8570328
    31.503645 165295.16400000002         322755.202 488050.36083984375 2013 21.084785 52.14098 .33868465  .00685969   .551754 .7258911  .4850223 .18308575 .21303587   .881144   .854805
    32.247738 172856.42200000002 328660.89699999994  501517.3151855469 2014  21.75276 52.48355  .3446669  .00598225  .3425713 .6679726  .4417405 .11602363  .1838393  .7416035  .7440929
    end
    Thank you all,

  • #2
    I have solved it with holes () , just had to change legend options to :
    HTML Code:
    rows(4) cols(2) holes(3 5 )

    Comment

    Working...
    X