Announcement

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

  • Twoway scatter, rcap by category

    Dear All,

    I want to plot a scatter and rcap plots for a categorical variable taking 3 categories. I use the following code:

    Code:
    twoway (scatter esi_b type if counter==1, msym(s) mcol(black)) || ///
            (rcap  esi_lci esi_uci type if counter==1, lcol(black)) || ///
      (scatter nonesi_b type if counter==1, msym(s) mcol(ltblue)) || ///
            (rcap  nonesi_lci nonesi_uci type if counter==1, lcol(ltblue)), ///
      yline(0, lcolor(cranberry)) ///
      legend(off) ///
      xlabel( 1 "I" 2 "II" 3 "III") ///
      xtitle("")
    Click image for larger version

Name:	Graph.png
Views:	1
Size:	20.8 KB
ID:	1578132

    But, I want the black and the blue plots to be placed *adjacent* to each other (slightly staggered from each other but still both roughly hovering over I) rather than the exact same X axis value. This will avoid the black and the blue lines from partially overlapping each other for category III. How can I do that? I will be very grateful for you help.

    Many thanks,
    Sumedha.

  • #2
    Create anoter "type" variable for second scatter by adding a decimal:

    Code:
    gen type2 = type+.2
    (scatter nonesi_b type2 if counter==1, msym(s) mcol(ltblue)) ||  ///
    (rcap nonesi_lci nonesi_uci type2 if counter==1, lcol(ltblue))
    Roman

    Comment


    • #3
      Thank you this worked well

      Comment

      Working...
      X