Announcement

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

  • How to add a diagonal line over a specific range

    Hello, Statalisters!


    Do you envisage a way to get the following result?

    To sum up, I need to connect two points .1551557 and .4425479 (x axis). I have been doing this manually, but it might exist a more elegant way.

    All the best,

    Tiago



    Code:
    clear
    set seed 12345
    set obs 10
    gene y = runiform()
    gene x = runiform()
    scatter y x

    Click image for larger version

Name:	Graph.png
Views:	1
Size:	86.0 KB
ID:	1428222

  • #2
    Here is one way for any two arbitrary points

    Code:
    gen n=_n
    twoway (scatter y x) (scatter y x if inlist(n, 3, 5), connect(direct) lcolor(navy) mcolor(navy) legend(off))

    Comment


    • #3
      See also help on twoway scatteri

      Comment


      • #4
        Thank you so much, Andrew and Nick for the helpful tips.

        All the best,

        Tiago

        Comment

        Working...
        X