Announcement

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

  • Help: Can't format xtline plot

    Dear community,

    I'm having three simple issues with with an 'xtline' plot.

    My plot looks as follows:
    Click image for larger version

Name:	Stata.png
Views:	5
Size:	122.0 KB
ID:	1482145



    My issues are the following:
    1. I want to change the titles per graph from say "1" in the first graph to a text of my choosing.
    2. I can't get rid of the bottom note "Graphs by group(countryname)
    3. I want to change the label "EC_INDEX" to a text of my choosing.

    My code:
    Code:
    xtline EC_INDEX EFW if ID==1|ID==2|ID==3|ID==6|ID==9|ID==11|ID==15|ID==19|   ///
                           ID==20|ID==21|ID==26|ID==27, ///
        recast(connected) ///
        ylabel(0(1)10, format(%9.0f)) xlabel(1996(4)2016, format(%9.0f))

    Any help, or reference to an explanation on how to solve this issues, will be appreciated.
    Attached Files

  • #2
    My issues are the following:
    1. I want to change the titles per graph from say "1" in the first graph to a text of my choosing.
    2. I can't get rid of the bottom note "Graphs by group(countryname)
    3. I want to change the label "EC_INDEX" to a text of my choosing.
    1. Add value labels
    2. Use the note("") option within the byopt() option
    3. Use the label option within legend().

    For example:
    Code:
    webuse grunfeld,clear
    label define mylabel 1 "AAA" 2 "BBB" 3 "CCC"
    label values com mylabel
    xtline invest kstock, byopt(note("")) legend(label(1 "My new label"))

    Comment


    • #3
      Thank you Scott,

      This solves most of my issues. I'm still having problems with the titles.
      Seems your code is labeling series sequentially, but I only need to use some of the series.

      For instance. These are countries, and I need to plot countries 1, 2, 3, and 6. That's their ID numbers. In another "column" I have the country names. I just can't figure out how to use the countrynames as the title (or subtitle) of each graph.

      Thank you again for your time.

      Comment


      • #4
        Just sort it out.
        Thank you again for your time.

        Comment


        • #5
          It is not necessarily sequential. I just did not want to write out labels for all 10 companies in the data set.

          If you have the names of the in a separate variable for the country id codes you can use Nick Cox's -labmask- to assign the values of the county names to the county id codes ( -search labmask- to locate and download).

          Code:
          webuse grunfeld,clear
          gen name = "Walmart" if com == 1
          replace name = "Apple" if com == 2
          replace name = "Berkshire Hathaway" if com == 8
          replace name = "Volkswagen" if com == 10
          keep if name != ""
          
          labmask com, values(name)
          xtline invest kstock, byopt(note("")) legend(label(1 "My new label"))
          Click image for larger version

Name:	Graph1.png
Views:	1
Size:	97.8 KB
ID:	1482393

          Comment

          Working...
          X