Announcement

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

  • Variable width bar graph

    Hello Nick.

    First of all, you are a legend plain and simple, and I am delighted to post my first Statalist question to you! Your responses over the years to queries have been enlightening and - at times - downright enjoyable.

    Is it possible to create a variable width bar graph using Stata? In the attachment below, I show variable spread along the y-axis that indicates return and variable width along the x-axis indicating relative investment.

    Please advise.
    Attached Files

  • #2
    See

    Code:
    help twoway bar
    You may also be interested in Nick's program -spineplot- which is available via the SSC archives.

    Comment


    • #3
      The answer is spanning bars, which were used in spineplot (SJ, SSC). Here's a stupid example:

      Code:
       
      clear
      input x y
      0   10
      2      9
      4     8
      7    6
      8    7
      9 42
      10 .
      end
      twoway bar y x, bartype(spanning)
      twoway bar y x, bartype(spanning) base(0)
      Different colours are a pain but achievable:

      Code:
       
      separate y, by(x) veryshortlabel 
      twoway bar y0 x, bartype(spanning) base(0) || bar y2 x, bartype(spanning) yla(0/10)
      and so on.

      The fullest account is now http://www.stata-journal.com/article...article=gr0063

      The last y value must be missing, as above, because you must have one more x value than you have y values.

      Comment


      • #4
        Gentlemen, these are wonderfully helpful responses. I can take it from here. Thank you.

        Comment

        Working...
        X