Announcement

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

  • changing the shapes in the legend

    Hello I produced this graph from this code

    Code:
    qnorm nobaby, xline(1.2, lc(black) lw(medthick)) xline(0.74, lc(black) lw(medthick)) xline(0.59, lc(black) lp(dash) lw(medthick)) legend (order(1 " study Population" 2 "oLD Ratio") col(1) pos(5) on)
    However I would like to change the green line to a solid black line.
    I would like to change the dot to a dashed black line

    The aim is to label the reference lines.

    I don't want labels on the graph as it looks cluttered.
    Click image for larger version

Name:	Screenshot 2023-10-19 at 16.03.13.png
Views:	1
Size:	404.9 KB
ID:	1730865


  • #2
    Creating a reproducible example here seems easy enough, right? Have you looked at

    Code:
    help qnorm
    ?

    Code:
    sysuse auto, clear
    qnorm weight, rlopts(lc(black) lw(medthick)) ms(none) mc(black) connect(l) lp(dash) lc(black)
    Click image for larger version

Name:	Graph.png
Views:	1
Size:	31.1 KB
ID:	1730889

    Comment


    • #3
      Dear Andrew, thank you for this.
      So just to confirm, can I leave the plot as a scatter with line of best fit as it is (post 1)

      But instead have a legend at 5 o'clock position - as it is, but instead within the legend i.e legend contents have:

      ---- = New ratio (which is the key to the broken reference line)
      _______ = Old ratio (which is the key to the reference line)

      Or is the only solution to label the reference lines ?

      Comment


      • #4
        You can use the -addplot()- option to add the reference lines and they will be in the legend.

        Code:
        sysuse auto,clear
        
        qnorm weight, rlopts(lc(black) lw(medthick)) ms(none) mc(black) connect(l)  lp(dash) lc(black)  /// 
            addplot(scatteri 5000 2000 1000 2000, recast(line) lc(green) /// 
            || scatteri 5000 4000 1000 4000, recast(line) lc(blue) )  /// 
             legend(order(3 "New Ratio" 4 "Old Ratio") pos(5) row(1))
        Click image for larger version

Name:	Graph.png
Views:	1
Size:	44.2 KB
ID:	1730916

        Comment

        Working...
        X