Announcement

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

  • Twoway bar with 2 y-axes

    Hi all,

    I'm trying to create a bar graph that shows how the numbers of procedures etc. required vary depending on the public service that you're applying for.
    I'm using "
    Code:
    twoway (bar Pages_Form_1 No_Forms type, yaxis(1)) (bar procedure type, yaxis(2))
    " and attached is the bar graph being produced. The numbers on the x-axis represent different public services (they've been converted to numbers so that I can use the twoway bar command. As seen in the image, the bars are currently stacked.




    Click image for larger version

Name:	ex.png
Views:	1
Size:	37.5 KB
ID:	1650993


    I want the bars to be unstacked. Any advice on how I can achieve that?

    TIA!

  • #2
    With your design the bars are not stacked; they are superimposed, which is quite different.

    Evidently your three outcome variables are already the result of a collapse. That being so, and given no data example, this example may help. Separate graphs are likely to be much easier to talk and think about.

    Code:
    sysuse auto, clear
    
    set scheme s1color 
    
    collapse turn trunk mpg , by(rep78)
    
    foreach v of var turn trunk mpg {
    su `v', meanonly 
    local max = 5 * ceil(r(max)/5)
    twoway bar `v' rep78, name(`v', replace) base(0) barwidth(0.8) xla(1/5) yla(0(5)`max', ang(h)) 
    }
    
    graph combine turn trunk mpg

    Comment


    • #3
      Alternatively, a dot chart can be much clearer than a bar chart and occlusion is almost never an issue.

      Code:
      sysuse auto, clear
      
      set scheme s1color 
      
      graph dot trunk mpg turn, over(rep78) linetype(line) lines(lc(gs12) lw(thin)) marker(1, ms(Oh)) marker(2, ms(+)) marker(3, ms(T)) legend(row(1)) l1title(Repair record)
      A detail is that I have found that the default dotted grid lines can degrade on porting elsewhere so I tend to inside on solid, thin, grey lines instead.

      Click image for larger version

Name:	multiple_means2.png
Views:	1
Size:	15.8 KB
ID:	1651019

      Comment


      • #4
        ... inside ... should be ... insist ....

        Comment

        Working...
        X