Announcement

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

  • twoway graph combine sharing same y-axis

    Dear Statalist,
    I am trying to combine towway graph , all these graph sharing the same y axis
    but when i combine it's still give 3 y-axis, i just want one y-axis, i am using ycommon but still have
    each graph have y-axis , i just want one y-axis. I am using example data.
    I install dataex in my stata 14.1 version but when i copy and past i did not have gray box.

    Thanks a lot

    code:

    use http://www.ats.ucla.edu/stat/stata/webbooks/reg/elemapi

    pwcorr api00 ell, sig
    graph twoway (lfitci api00 ell) ///
    (scatter api00 ell) ///
    , ytitle("api00") ///
    legend(region(lwidth(none)) ring(0) pos(5) order(2 "linear fit" 1 "95% CI")) ///
    text(900 60 "corr=-0.76" "p-value=0.00",size(small))

    graph save "api00_ell.gph", replace

    pwcorr api00 meals, sig
    graph twoway (lfitci api00 meals) ///
    (scatter api00 meals) ///
    , ytitle("api00") ///
    legend(region(lwidth(none)) ring(0) pos(5) order(2 "linear fit" 1 "95% CI")) ///
    text(900 80 "corr=-0.82" "p-value=0.00",size(small))

    graph save "api00_meals.gph", replace

    pwcorr api00 mobility, sig
    graph twoway (lfitci api00 mobility) ///
    (scatter api00 mobility) ///
    , ytitle("api00") ///
    legend(region(lwidth(none)) ring(0) pos(5) order(2 "linear fit" 1 "95% CI")) ///
    text(900 40 "corr=-0.21" "p-value=0.00",size(small))

    graph save "api00_mobility.gph", replace


    graph combine api00_ell.gph api00_meals.gph api00_mobility.gph, ///
    ycommon col(3) ///
    graphregion(color(white))
    Attached Files

  • #2
    Originally posted by suganthiny kumarasamy View Post
    I am trying to combine towway graph , all these graph sharing the same y axis
    They are not sharing same axis. They have same scales but you have distinct commands for distinct three graphs thus three axis.


    Originally posted by suganthiny kumarasamy View Post
    i just want one y-axis, i am using ycommon but still have
    each graph have y-axis , i just want one y-axis.
    If you want only one axis and all plots overlayed, that may not look as what you want. However the commands for overlaying will be the following. I ignored the texts and customization, which you can do as you want but you will get one y-axis.

    Code:
    graph twoway (lfitci api00 ell) || ///
                (scatter api00 ell) || ///
                (lfitci api00 meals)|| ///
                (scatter api00 meals) || ///
                (lfitci api00 mobility) ///
                (scatter api00 mobility)

    Originally posted by suganthiny kumarasamy View Post
    Dear Statalist,
    i am using ycommon but still have each graph have y-axis , i just want one y-axis.
    ycommon is an option to have same y-scale for all the graphs that are being combined and that does not mean one axis:



    Originally posted by suganthiny kumarasamy View Post
    Dear Statalist,
    am using example data.
    I install dataex in my stata 14.1 version but when i copy and past i did not have gray box.
    Use the code delimiter from the right hand side corner. Click the A button and then click the # button. Write/paste your data inside the two 'code' delimiters.
    Roman

    Comment


    • #3
      You can use the yscale(off) option in the last two graphs

      Comment


      • #4
        That is a good option suggested by Oded which will give you three distinct graphs with one yaxis, then you need to allow -col(3)- option in the -graphcombine- command otherwise you may end up having one graph in the second row without any scale.
        Roman

        Comment


        • #5
          thank you so much for your comments

          Comment

          Working...
          X