Announcement

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

  • graph combine and making grids fit

    Hi
    I'm using the code:
    Code:
    cls
    sysuse auto, clear
    
    local x mpg
    local y price
    scatter `y' `x' , ///
        ylabel(0(5000)15000, grid) xlabel(10(5)45, grid) ///
        yscale(off) xscale(off) ///
        plotregion(lcolor(none) margin(zero)) ///
        name(yx, replace)
    twoway histogram `y' , ///
        percent xscale(off) horizontal ///
        fxsize(25) fysize(100) ///
        plotregion(lcolor(none) margin(zero)) ///
        ylabel(0(5000)15000, grid) ///
        name(hy, replace)
    twoway histogram `x' , ///
        percent yscale(off) ///
        fxsize(100) fysize(25) ///
        plotregion(lcolor(none) margin(zero)) ///
        xlabel(10(5)45, grid) ///
        name(hx, replace)
    graph combine hy yx hx, hole(3) imargin(0 0 0 0)
    to get the following graph:
    Click image for larger version

Name:	Graph.png
Views:	1
Size:	16.8 KB
ID:	1645612


    My problem is that the vertical grids don't match.
    Does anyone have a solution?
    Last edited by Niels Henrik Bruun; 18 Jan 2022, 05:51.
    Kind regards

    nhb

  • #2
    Found the solution myself: Just remove "fysize(100)" in the code above
    Kind regards

    nhb

    Comment


    • #3
      Nice Niels,

      But, I think also fxsize(100) has to be removed, at least at my system, the code now used is:
      Code:
      cls
      sysuse auto, clear
      
      local x mpg
      local y price
      scatter `y' `x' , ///
          ylabel(0(5000)15000, grid) xlabel(10(5)45, grid) ///
          yscale(off) xscale(off) ///
          plotregion(lcolor(none) margin(zero)) ///
          name(yx, replace)
      twoway histogram `y' , ///
          percent xscale(off) horizontal ///
          fxsize(25) /// fysize(100)
          plotregion(lcolor(none) margin(zero)) ///
          ylabel(0(5000)15000, grid) ///
          name(hy, replace)
      twoway histogram `x' , ///
          percent yscale(off) ///
          fysize(25) /// fxsize(100) 
          plotregion(lcolor(none) margin(zero)) ///
          xlabel(10(5)45, grid) ///
          name(hx, replace)
      graph combine hy yx hx, hole(3) imargin(0 0 0 0)
      Which results in:

      Click image for larger version

Name:	Example_Niels_Henrik_Bruun_combine_scatter_histogram.png
Views:	1
Size:	55.7 KB
ID:	1645663
      http://publicationslist.org/eric.melse

      Comment


      • #4
        ericmelse: thank you for noticing I actually did remove fxsize(100) as well. But it should also be clear in this forum.
        Kind regards

        nhb

        Comment

        Working...
        X