Announcement

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

  • twoway yaxis - how to decrease range without squeezing graph?

    Dear Forum

    I am having problems with scaling the yaxis without compressing the graph - what am I doing wrong? (I just want the yaxis to fit my collapsed dataset)



    Code:
    preserve
    replace avr_co_7 = avr_co_7*1000
    drop if id==32
    drop if id==25
    **generating vars for plot
    gen log1=log(avr_co_7)
    collapse (mean) meanlog= log1 (mean) mean1=avr_co_7 (sd) sd1=log1 (count) n=log1, by(p3 strain)
    generate hi_1 = meanlog + invttail(n-1,0.025)*(sd1 / sqrt(n))
    generate low_1 = meanlog - invttail(n-1,0.025)*(sd1 / sqrt(n))
    gen hi1 = exp(hi_1)
    gen low1 = exp(low_1)
    *graph bar mean1, over(p3) over(strain) name(p2, replace)
    egen Group=group(strain p3)
    replace Group=9 if Group==8
    replace Group=8 if Group==7
    replace Group=7 if Group==6
    replace Group=6 if Group==5
    **Figure
    twoway (bar mean1 Group, barwidth(0.9)) ///
    (rcap hi1 low1 Group) ///1"D2 ; FRL"
    , xlabel(0 " " 1 "D2" 2 "P" 3 "E" 4 "D1" 5 " " 6 "D2" 7 "P" 8 "E" 9 "D1" 10 " ", noticks) ///
    xtitle("GBC LPS" ) ytitle("ng/g brain") ysc(alt) ///
    b1title("Estrous cycle effects") legend(off) note("Cytokines", bc(red)) ///
    name(p6, replace)
    restore


    My attempt to rescale includes:
    name(p6, replace) ysc(r(200)) ylabel(0[50]200)
    (in the last line)

    Thank You
    Plot WITHOUT yscr/label command Plot with yscr/label

  • #2
    You neglected to mention that you are using the economist scheme, which creates square graphs by default. Use the xsize() and ysize() options.
    Code:
    set scheme economist
    sysuse sp500
    twoway bar change date in 1/57, name(g1)
    twoway bar change date in 1/57, xsize(4) ysize(2) name(g2)
    Please note the preference for full real names on Statalist. Section 6 of the FAQ explains how you can change your name.
    Last edited by Friedrich Huebler; 18 Nov 2015, 07:42.

    Comment


    • #3
      Thank you for your suggestion, however it does not help. And I have the excact same problem using other schemes.

      Is there no command for combining graphs and making sure that all plot regions are the same size?!

      Comment


      • #4
        Please try again.
        Code:
        set scheme economist
        sysuse sp500
        twoway bar change date in 1/57, name(g1)
        twoway bar change date in 1/57, xsize(4) ysize(2) name(g2)
        twoway bar change date in 1/57, yscale(r(-55 65)) ylab(-50(10)60) name(g3)
        twoway bar change date in 1/57, xsize(4) ysize(2) yscale(r(-55 65)) ylab(-50(10)60) name(g4)
        If the third and fourth graph are not what you have in mind, please give a more precise description of your problem. The statement in post #3 is too vague to analyze what you are trying to do and why you don't get the desired result. Please refer to section 12 in the FAQ for useful advice on information that should be included in posts.

        Comment

        Working...
        X