Announcement

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

  • Combining graphs with equal sizes

    Hi there,

    I want to combine 3 bar graphs in one row. The y-axis labels should only appear once on the first graph. When I hide the y-axis of the other two graphs they become wider than the first graph. How can I make them all of the same width?

    Any help is highly appreciated!

    Thanks,
    Tobias
    Click image for larger version

Name:	mi_ai_xi_prob_combined.png
Views:	1
Size:	77.5 KB
ID:	1359769

  • #2
    You can fiddle with the fysize() and fxsize() options before combining graphs . But I usually recast the problem to reshape the data somehow to make the different graphs come under the aegis of a by() option. Then what you want is automatic.

    I can give concrete advice for your problem, but as you show no data and no code it's too much like hard work even to invent an analogue for your problem.

    Please see FAQ Advice #12 on showing data examples. (And also #6 on our request to give full real names.)

    Comment


    • #3
      I've tried fxsize() but couldn't find the right ration between the graph including the axis and the other two graphs (any hints on how to find the right sizes to use are very welcome). I now use the following workaround with yscale(off fill) and imargin(tiny) which is not a pretty solution but I can live with the result.

      Code:
      twoway (bar meanmi type), xtitle("") ylabel(0 (1) 6, labsize(small))  subtitle("M-Fund") 
      graph save mi, replace
      
      twoway (bar meanai type), xtitle("")  yscale(r(0 6) off fill) subtitle("A-Fund")
      graph save ai, replace
      
      twoway (bar meanxi type), xtitle("") yscale(r(0 6) off fill) subtitle("P-Fund")
      graph save xi, replace
      
      graph combine mi.gph ai.gph xi.gph, ycommon rows(1) imargin(tiny)
      Click image for larger version

Name:	mi_ai_xi_prob_combined.png
Views:	2
Size:	78.1 KB
ID:	1359781
      Attached Files

      Comment


      • #4
        The graphs don't correspond to the code, but in details secondary to the question.

        The fake data here and the code show my approach of reshaping temporarily.

        Code:
        clear
        set scheme s1color 
        set obs 4 
        set seed 2803 
        gen type = word("symL symH asymDL asymD", _n) 
        gen meanmi = rnormal(3, 1) 
        gen meanxi = rnormal(2, 0.5) 
        gen meanai = rnormal(5, 1.5)
        preserve 
        rename (meanmi meanxi meanai) (mean1 mean2 mean3) 
        reshape long mean, i(type) j(which) 
        label def which 1 "M-Fund" 2 "X-Fund" 3 "P-Fund" 
        label val which which 
        label def type 1 symL 2 symH 3 asymDL 4 asymD 
        encode type, gen(TYPE) label(type) 
        twoway bar mean TYPE, by(which, row(1) note("") compact) xtitle("") barw(0.5) xla(1/4, tlength(0) valuelabel labsize(small)) 
        restore
        Click image for larger version

Name:	barbywhatever.png
Views:	1
Size:	37.3 KB
ID:	1359793

        Comment


        • #5
          This is a very elegant solution indeed. Thanks for providing it!

          And yes, the code I posted above does not correspond exactly to the graphs. I excluded the meaningless parts of the code to make it more to the point.

          Comment

          Working...
          X