Announcement

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

  • How to connect points to lines by entity (panel data) in twoway line graph

    Dear all,
    I'm making a twoway line graph. My data is as follows,

    Company year RDint typeNbChange sumTypeNbChange
    3M 2016 4.0685509 9 18
    3M 2014 3.7490965 0 18
    3M 2013 3.725179 0 18
    3M 2012 5.464152 0 18
    3M 2017 4.1918059 0 18
    3M 2018 3.8089425 18
    3M 2015 4.0397701 -9 18
    3M 2011 3.4986998 0 18
    ABBOTTLABORATORIES 2015 6.7189414 0 5
    ABBOTTLABORATORIES 2014 6.6429595 0 5
    ABBOTTLABORATORIES 2017 7.8787879 0 5
    ABBOTTLABORATORIES 2018 7.4825038 5
    ABBOTTLABORATORIES 2012 10.843659 0 5
    ABBOTTLABORATORIES 2016 6.7951853 0 5
    ABBOTTLABORATORIES 2013 6.6459172 0 5
    ABBOTTLABORATORIES 2011 10.628778 5 5
    ACTELION 2015 21.458611 0 3
    ACTELION 2016 22.167352 3
    ACTELION 2011 25.483015 0 3
    ACTELION 2012 26.641522 0 3
    ACTELION 2014 22.342693 -3 3
    ACTELION 2013 22.695689 0 3
    ACTIVISIONBLIZZARD 2016 14.497579 0 8
    ACTIVISIONBLIZZARD 2012 12.438221 0 8

    I tried this code

    twoway line RDint year if sumTypeNbChange==1, sort by(Company, title("home to host transformation"))

    But, it connected the correct lines, but in different windows, as follows,
    Click image for larger version

Name:	Graph.png
Views:	1
Size:	63.8 KB
ID:	1561341

    What can I do to put the lines in the same window but in different colors?
    Thank you in advance for answering!


  • #2
    I also tried the code
    separate RDint if typeNbChange ==8, by(Country) veryshortlabel
    scatter RDint? year if typeNbChange ==8, ytitle("`:var labe windspeed`") yla(,ang(h)) legend(pos(40) ring(0) order(14 13 12 11 10 9 8 7 6 5 4 3 2 1) col(1))
    but stata warns "too few quotes"
    Last edited by Johnny YANG; 30 Jun 2020, 18:14.

    Comment


    • #3
      Hi guys, now it works! But the graph is still not what I want. Cause the scattered points all overlap with each other. Do you have a solution for that? My new code is as follows,

      separate RDint if typeNbChange ==1, by(Company) veryshortlabel
      scatter RDint? year if typeNbChange ==1, ytitle("`:var label RDint'") yla(,ang(h)) legend(pos(11) ring(0) order(9 8 7 6 5 4 3 2 1) col(1))

      Comment

      Working...
      X