Announcement

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

  • Variable labels in graph's legend

    Hey everyone,

    I need to create 64 scatter plots, which I then combine for comparison. I use a loop to set up all 64 graphs in order to use -graph combine- later on. In that Loop (see below) I would like to display the variable labels in the legend and xtitle of the graphs instead of the variable's name. However, I could not find a way to address the individual variable labels. Anybody with some advice on how to implement that?

    Code:
    foreach var in capt cont cit inct pit propt ssc vat {
     forvalues i = 1/8 {
     twoway rcap ci_low`var' ci_high`var' q`i', lstyle(ci) ||   ///
     scatter `var' q`i', mstyle(p1) mcolor(navy)  ///
     legend(order(1 "95% CI" 2 " `var' Coefficients")) ///  *** Display the lable of var here
     legend(size(vsmall) height(2) width(90) row(1)) /// 
     xtitle("Ranked capital intensities q`i'") /// ****same here for my q-variables
     name(`var'_`i', replace)
     }
    }
    Cheers
    Philipp

  • #2
    Maybe try something like:

    Code:
     
     foreach var in capt cont cit inct pit propt ssc vat {  forvalues i = 1/8 {  twoway rcap ci_low`var' ci_high`var' q`i', lstyle(ci) ||   ///  scatter `var' q`i', mstyle(p1) mcolor(navy)  ///  legend(order(1 "95% CI" 2 `" `: var label `var'' Coefficients"')) ///  *** Display the lable of var here  legend(size(vsmall) height(2) width(90) row(1)) ///   xtitle(`"Ranked capital intensities `: var label q`i''"') /// ****same here for my q-variables  name(`var'_`i', replace)  } }
    It's a bit challenging to provide truly useful/helpful examples without being able to replicate things, but if you read the help for extended macro functions that should help you out quite a bit.

    Comment


    • #3
      Dear wbuchanan,

      Thank you so much for your advice. The code works perfectly now.

      Cheers

      Philipp

      Comment

      Working...
      X