Announcement

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

  • How to add scatter plot to xtline and modify its colours accordingly

    Hi, I'm trying to add orginial data to xtline. Sometimes a unit exhibits a constant variable over severals years, and here I want to distinguish whether a flat line is due to, say 5 consecutive same values or due to only 2 same values with 3 gaps in between. I managed to code something like this in another software. For the green case, there are 3 years data for 5 year with gaps in between.

    Click image for larger version

Name:	xtline.png
Views:	1
Size:	10.2 KB
ID:	1507766

    How can I finally modify the colour of data points? Sometimes data overlaps, and I need colour to distinguish between cases. I also don't need the additional var-label in the legend, which is created automatically. Here is some similar MWE:

    Code:
    clear
    input     year     pid var
            2003     513 1500    
            2004     513 1550
            2005     513 1500    
            2006     513 1600    
            2003     514 1600    
            2004     514 1600
            2005     514 1700    
            2006     514 1800            
    end
    xtset pid year
    xtline var, overlay addplot(scatter var year)
    Best regards


  • #2
    Some ideas at https://www.statalist.org/forums/for...using-linkplot

    Comment

    Working...
    X