Announcement

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

  • Add a gap/space between graph title and the plot region

    Hi Statalists,

    Recently I have been using the graph module of Stata, and a seemly simple issue came up, such that I failed to figure out how to increase the space between a graph TITLE (neither xtitle nor ytitle) and plot region. I have searched the manuals and it seems like there is no such solution in the "title" suboptions . Am I missing anything? Any thought is welcome and appreciated!

    Thanks in advance,
    Yingyi

  • #2
    I suppose, Lin, you struggle with something like this:

    Code:
    sysuse auto
    twoway scatter price weight, title(My title, color(blue) box fc(sand) lc(sand))
    which results in:
    Click image for larger version

Name:	GraphTitleExample2.png
Views:	1
Size:	40.6 KB
ID:	1468622


    Now you want to increase (control) the distance between your graph's title and the plot area. As far as I am aware there is no regular option to set that, but you will get what you want by introducing an empty subtitle, but note that a space character is required, and using the margin parameters to control the distance of the box of the subtitle, like:
    Code:
    twoway scatter price weight, title(My title, color(blue) box fc(sand) lc(sand)) subtitle(" ", margin(l+0 r+0 b-1 t-1)
    Click image for larger version

Name:	GraphTitleExample1.png
Views:	1
Size:	40.3 KB
ID:	1468621


    Much more information about creating graphics with Stata is available in the help file and PDF documentation and for almost anything else you could buy the print or ebook version of A Visual Guide to Stata Graphics, Third Edition.

    I hope this is helpful.
    http://publicationslist.org/eric.melse

    Comment


    • #3
      You can just specify a (larger than default) bottom margin on the title itself:

      Code:
      twoway scatter price weight, title(My title, color(blue) box fc(sand) lc(sand) margin(b=5))
      Click image for larger version

Name:	GraphTitleMargin.png
Views:	1
Size:	18.0 KB
ID:	1468646

      Comment


      • #4
        Hi Eric and Nicholas, thanks for your reply and both of your solutions perfectly solve the issue.

        Thanks again!
        Yingyi

        Comment

        Working...
        X