Announcement

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

  • twoway rcap with x-axis labels from a fourth variable?

    I have a twoway rcap graph of variables y1 and y2 against a variable x. x consists of a small set of unique, possibly non-consecutive integers. I would like to label the x axis using strings in a fourth variable, x_labels. Is this possible?

    I suppose this is similar to the mlabel(varname) marker_label_option, except I would like the marker labels to behave like xlabels (e.g. be able to control the angle).

    I think I could program around this using something along the lines of

    ----

    local x_labels `""'
    sort x
    gen x_n = _n if !mi(x)
    qui summ x_n
    local max_x_n = `r(max)'

    forvalues i = 1/`max_x_n' {
    local xvalue_i = x[`i']
    local xlabel_i = xlabels[`i']
    local x_labels `"`x_labels' `xvalue_i' "`xlabel_i'""'
    }

    label define x_label `x_labels', replace
    lab val x x_label
    twoway rcap y1 y2 x, xlabel(,valuelabel)

    ----

    but if there is a more direct way I would prefer that.

  • #2
    labmask from SJ should help.

    Comment


    • #3
      Thanks Nick, that indeed works very well.

      Comment

      Working...
      X