Announcement

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

  • How can I use a variable's value label as graph titles?

    Hello. I have a panel data set on seven currencies across time. In order to analyze the data, I created a variable that I called CoinId in order to uniquely identify each observation together with my time variable. The variable CoinId takes a value from 1 to 7, each of them referring to a different currency (for example, 1=Euros, 2=Dollars,..., 7=Pesos) and as mentioned before, I've used it as my Panel ID Variable.

    I'm now plotting graphs of several independent variables with xtline command, which appear separated by currency type as I wanted, but I'd like the title of each Graph to be the variable value label (Euros, Dollars...). Is there a command line to do so or do I have to do it manually? I've read Stata's documentation on xtline and on graphs extra features, but I can't find a useful solution.

    Thank you in advance.

  • #2
    Not sure exactly what you're doing without example code or graphs. If each graph is one panel, then value labels should show up automatically..

    For multiple lines, you can use separate, veryshortlabel as documented at https://journals.sagepub.com/doi/pdf...867X0500500412

    There is a more direct route with the same trick under the hood: Use sepscatter from SSC. The announcement at https://www.statalist.org/forums/for...lable-from-ssc doesn't spell out the line plot application, but it is quite simple.


    Code:
    webuse grunfeld, clear
    
    ssc install sepscatter 
    
    sepscatter invest year, separate(company) recast(line) ysc(log) legend(pos(3) col(1)) yla(1 10 100 1000)
    In this case, and many others, direct labelling is probably better than a legend.

    Comment

    Working...
    X