Announcement

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

  • Spacing of Numbers in Graph

    This may seem like an odd quip, I'm just super detail oriented.
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input double(_Y_treated cf_adh year cf_pcr cf_scul) float(adhdiff sculdiff pcrdiff)
     123077.921875 129459.29132812501 1999 121500.31198647656 123598.55058260645   -6381.37  -520.6287    1577.61
    127079.9609375   139672.004921875 2000 127900.87078433114 129318.99478593418 -12592.044  -2239.034  -820.9099
        134089.625  147392.6341015625 2001  138424.3539188703  135077.5821944244  -13303.01  -987.9572  -4334.729
      152750.40625  158667.9578515625 2002 150339.53671566144 150902.29149945057  -5917.552  1848.1147  2410.8696
     155233.859375  161715.1296484375 2003  154985.9516934131 155478.01854029225  -6481.271 -244.15916   247.9077
     159758.296875 163546.47617187502 2004 159092.65022559854 159252.86977807098  -3788.179   505.4271   665.6467
     166989.453125  167311.7707421875 2005 166027.04221549898 166386.89734957635  -322.3176   602.5558   962.4109
     174474.328125   176369.961015625 2006 173402.40339984905 173723.41575660423  -1895.633   750.9124  1071.9247
       181731.6875     178687.8584375 2007 182675.86327817535 181461.07304273036   3043.829  270.61447  -944.1758
       182551.9375   179965.169296875 2008 185811.82705650147 183532.14967944042   2586.768  -980.2122   -3259.89
      182221.03125   174798.564140625 2009 179901.40387348167 180992.23901184904   7422.467  1228.7922  2319.6274
     166796.734375    164813.47515625 2010 166568.41727799363 166345.81288047842  1983.2593   450.9215   228.3171
        153637.625  142907.2965234375 2011 155619.20956979156 155539.03269330366  10730.328 -1901.4077 -1981.5846
      146016.34375 129614.04652343752 2012  144912.9704307675 145327.50448423624  16402.297   688.8393  1103.3733
      143775.53125 128247.07933593751 2013    144280.12056575  144436.4556766758  15528.452  -660.9244  -504.5893
     146594.796875  135096.6670703125 2014 146407.88804234276 147079.71905356567   11498.13  -484.9222  186.90883
     153234.828125 145899.91812500003 2015  154371.9449025044  153322.4117105577    7334.91  -87.58359 -1137.1168
     162161.859375  154564.1108984375 2016  159953.4606254927  160401.2078427034   7597.749  1760.6515  2208.3987
       166058.4375    161167.01515625 2017 164607.59593921603 163487.69483554334   4891.422   2570.743  1450.8416
      176226.03125       174247.44125 2018 174091.67374286606 171751.76229264925    1978.59   4474.269  2134.3574
     182729.203125   185289.537890625 2019  182624.5401193591  180559.8570116175  -2560.335  2169.3462    104.663
    end
    
    qui mean *diff if year > 2016
    
    loc adh: di %8.4g e(b)[1,1]
    loc scul: di %8.4g e(b)[1,2]
    loc pcr: di %8.4g e(b)[1,3]
    
    qui ssc install schemepack, replace
    
    twoway (line _Y_treated year, lcolor(black) lwidth(medthick)) || ///
        (line cf_a year, lcolor(red) lwidth(thin)) || ///
        (line cf_p year, lcolor(blue) lwidth(thin)) || ///
        (line cf_s year, lcolor(lime) lwidth(thin)), ///
            xli(2017, lcolor(black) lwidth(thick)) ///
            note("    ATTs: ADH: `adh' SCUL: `scul' RSC: `pcr'", pos(12) ring(0) size(*1.4)) ///
            legend(order(1 "Cobb" 2 "ADH Cobb" 3 "SCUL Cobb" 4 "RSC Cobb") ///
            pos(10) ring(0)) scheme(gg_tableau) ///
            yti("Average Housing Prices") xti(Year)
    Look at the numbers for the ATT: for Abadie, Diamond, and Hainmuller, it's presented as "ADH: 1437". The same with the other two- the numbers are like, four spaces away from the colon, even though the syntax just has one space after the colon. How might I solve this? Ideally, the note would just look like "ATTs: ADH: 1437 SCUL: 3071" and so on, with just one space after the colon. Perhaps it's related to how I stored the ATTs above?
    Last edited by Jared Greathouse; 13 Apr 2022, 10:45. Reason: Added the syntax to install the graph scheme I use for complete replicability.

  • #2
    Thanks for the data example. Your code fails for me because it's assumed that scheme gg_tableau is installed.

    Comment


    • #3
      Code:
      . loc adh: di %8.4g e(b)[1,1]
      
      . loc scul: di %8.4g e(b)[1,2]
      
      . loc pcr: di %8.4g e(b)[1,3]
      
      . display ">`adh'< >`scul'< >`pcr''<"
      >    1437< >    3071< >    1230'<
      
      .
      . loc adh = trim("`adh'")
      
      . loc scul = trim("`scul'")
      
      . loc pcr = trim("`pcr'")
      
      . display ">`adh'< >`scul'< >`pcr''<"
      >1437< >3071< >1230'<
      Last edited by William Lisowski; 13 Apr 2022, 10:51.

      Comment


      • #4
        Yes Nick Cox my apologies, I'm using the schemes from here. These have become my favorite for some reason.

        And thank you William Lisowski , this worked.

        Comment


        • #5
          This too works in your circumstances.
          Code:
          . display ">`adh'<"
          >    1437<
          
          . local adh `adh'
          
          . display ">`adh'<"
          >1437<
          It would perhaps be problematic in more complicated circumstances.

          Comment

          Working...
          X