Announcement

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

  • How to add a line to a stacked bar graph?

    I have a stacked bar graph of 2 variables over years. I want to add a line for year information of another varaible (or another stacked bar of 2 varaibles over years if possible)

    My current code :

    graph bar (asis) full_puty full_cally if dec2==10, over(year, label(labsize(vsmall))) stack bar(1, fcolor(gs8) lcolor(black)) bar(2, fcolor(gs14) lcolor(black)) title(Proportion of contracts in Top IS Decile) legend(order(1 "Put" 2 "Call" ))



    Click image for larger version

Name:	All_year_Putcall.png
Views:	1
Size:	51.8 KB
ID:	1704284


  • #2
    Adding a line could mean one of adding

    1 a constant

    2 a straight line with specified slope

    3 a series shown by a segment line.

    If it's either #2 or #3 you probably need to switch to twoway bar etc.

    That said, what I see in your graph is that the proportion of Put varies a bit around 0.6 and that the proportion of Call correspondingly varies a bit around 0.4. I would choose the more interesting or important of the two and use a line or dot chart to show the variations more directly.

    Comment


    • #3
      Sorry for not being clear. Forget about the line, what about if I want to add another stacked bar for each year that includes de information of other two varaibles, let say full_XXX full_YYY

      Comment


      • #4
        Basically combining these two plots, where the bars for each year are together




        Click image for larger version

Name:	Fig3_All_year_Putcall.png
Views:	1
Size:	56.1 KB
ID:	1704314

        Comment


        • #5
          Another stacked bar chart is to be produced in the same way, I guess. You don't show a data example, so the code can only be guessed at as being similar.

          Comment

          Working...
          X