Announcement

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

  • Twoway graph X axis

    Hi all,

    Would anyone know whether there is a similar over () function such as with the graph bar (asis) command that can be used with the twoway stacked bar command?

    I have a created a stacked bar graph over weeks in the x axis and would like to also include months in the x axis as well.

    graph twoway (bar AGE_N_0_4 week,color(black) lcolor(black)lwidth(medthick)) (rbar AGE_N_0_4 A2 axis ,color(gs7*0.9) lcolor(black)lwidth(medthick)) (rbar A2 A3 week,color(gs7*0.4) lcolor(black)lwidth(medthick)) (rbar A3 A4 week,color(dimgray) lcolor(black)lwidth(medthick))(rbar A4 A5 week,color(white) lcolor(black)lwidth(medthick)) (line THREE_WEEK_AVERAGE_COUNT week, lpattern(solid)color (red) recast(connected) msymbol(O))(line TWO_SD_THREE_WEEK_COUNT week, lpattern(dash)color (blue) recast(connected) msymbol(x))(line HISTORICAL_AGERAVE week, lpattern(dash)color (gray) recast(connected) msymbol(s)),xlabel(1(2)62,valuelabel angle(90) labsize(*1.0)tick)xtick(1(1)62) ytitle("X", size(small) height(4)) ylabel(,nogrid)graphregion(color(white)) ylabel(0(1)10, labsize(*1.0)angle(0))

  • #2
    Use a by() option instead.

    Comment


    • #3
      Hi Nick,

      I have tried that, however it is not quite what I am looking for. I don’t want to get 12 different graphs. I want one graph that gives me the week labels and under that the months under which the weeks fall. With Bar (Asis) I would have been able to do this by including two over() options.

      Comment


      • #4
        Is there a way to group the weeks similar to how this Y axis is set up? does the twoway command support groups?

        Click image for larger version

Name:	stata_ex.JPG
Views:	1
Size:	59.3 KB
ID:	1529830

        http://repec.sowi.unibe.ch/stata/coe...labelling.html

        Comment


        • #5
          Yes and no. You just need to work out where on one axis values are to be plotted. For example, as in your plot, you could use positions say at 1 3 4 5 7 8 10 11 12 13 14 leaving gaps at 2 6 9. The code is simple in principle and a little tedious in practice.

          Code:
          search seqvar
          should find a relevant paper, but many programs use the same logic.

          Comment


          • #6
            Thank you Nick! I have used labmask before, I used it to create my week variable. However I am not sure how to incorporate labmask and the information you provided above into my command below. Do you have an example of a twoway graph where it has been used in the way I am hoping to?

            Code:
            graph twoway (bar AGE_N_0_4 week,color(black) lcolor(black)lwidth(medthick)) (rbar AGE_N_0_4 A2 axis ,color(gs7*0.9) lcolor(black)lwidth(medthick)) (rbar A2 A3 week,color(gs7*0.4) lcolor(black)lwidth(medthick)) (rbar A3 A4 week,color(dimgray) lcolor(black)lwidth(medthick))(rbar A4 A5 week,color(white) lcolor(black)lwidth(medthick)) (line THREE_WEEK_AVERAGE_COUNT week, lpattern(solid)color (red) recast(connected) msymbol(O))(line TWO_SD_THREE_WEEK_COUNT week, lpattern(dash)color (blue) recast(connected) msymbol(x))(line HISTORICAL_AGERAVE week, lpattern(dash)color (gray) recast(connected) msymbol(s)),xlabel(1(2)62,valuelabel angle(90) labsize(*1.0)tick)xtick(1(1)62) ytitle("X", size(small) height(4)) ylabel(,nogrid)graphregion(color(white)) ylabel(0(1)10, labsize(*1.0)angle(0))

            Comment


            • #7
              Even with some experience I can’t happily read your code and have any precise idea of what you want to do.

              To get more advice I think you need to post

              * example data

              * your graph so far

              * details of what you to do further.

              Please read FAQ Advice #12 and act on it.

              Comment

              Working...
              X