Announcement

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

  • add text outside of the plot region of line graph

    Hello!

    I am making a line graph and want to label the line on the right side of the graph, outside of the plot region.

    For example, instead of the graph produced with this
    sysuse sp500
    line close date, xlab(,format(%tdCCYY)) text(1190 15320 "S&P500")


    I would like the label "S&P500" to be to the right of line, outside of the plot region.

    Thank you for any guidance.

  • #2
    You can use the range() option within xscale() to expand the x axis

    Code:
     line close date, xlab(,format(%tdCCYY)) text(1190 15370 "S&P500") xscale(range(15370))

    Comment


    • #3
      Thank you. However I do not want the x axis---or, at least, a visible portion of the x axis---to extend. For example, see the below graph from the Congressional Budget Office's Trends in Family Wealth, 1989 to 2013. Note how the labels for the lines are in the margin.
      Click image for larger version

Name:	Capture.PNG
Views:	1
Size:	50.8 KB
ID:	1397027


      (https://www.cbo.gov/publication/51846)

      Comment


      • #4
        You can use graphregion().
        Code:
        line close date, xlab(,format(%tdCCYY)) text(1190 15370 "S&P500") graphregion(margin(3 15 1 3))

        Comment


        • #5
          EXACTLY! Statalist comes through again. Many thanks.

          Comment

          Working...
          X