Announcement

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

  • Why Does the Plotregion Grow in my Twoway Graph?

    Good evening, everyone.

    I’m trying to create a twoway graph that combines scatteri and pci graphs.

    However, when I attempt to graph it, something strange happens: sometimes the plotregion adds space at the bottom, other times on the left, and in some cases at both the top and bottom. You can see it more clearly in the figures: The plotregion is displayed in yellow, while the graphregion is blue. Red rectangles are drown through two-way too and they should be the limits of the graph: after checking multiple times, none of the other twoway graphs extend beyond the square.

    I’ve tried adjusting the xsize and ysize values, but that doesn’t remove the yellow space outside the square. I also tried specifying a range within xscale and yscale, but that didn’t work either.

    What am I missing here?

    Click image for larger version

Name:	gr1.jpg
Views:	1
Size:	34.1 KB
ID:	1765762
    Click image for larger version

Name:	gr2.jpg
Views:	1
Size:	46.2 KB
ID:	1765763
    Click image for larger version

Name:	gr3.jpg
Views:	1
Size:	40.7 KB
ID:	1765764


  • #2
    Look at options that allow you to explicitly specify the plot region margins. Otherwise, the images alone are not sufficient. If you want better responses, provide a reproducible example that highlights the issue. See FAQ Advice #12 for details.

    Comment


    • #3
      Thank you, Andrew Musau.

      I finally managed to find the issue: it’s the axis labels!

      In my graphs, the axes were hidden using xscale(off) yscale(off), but despite this, they were still there somehow, and Stata was calculating the ticks and labels according to its default settings. Sometimes my graph ended at 12, but Stata created the following ticks and labels: 0, 5, 10, and 15, which caused extra space to appear (from 12 to 15).

      The solution was very simple: I just added
      Code:
      xlabel(minmax) ylabel(minmax)
      , and the problem was solved.

      Comment

      Working...
      X