Announcement

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

  • Creating reference lines, which are annotated in the legend - what's wrong with my code

    I'm using the following code and obtaing the following graph
    The only issue is that I am not seeing the reference lines plotted - I would like to plot reference line (green x 0.59 y 1.5) ; reference line blue (x 0.74 y 1.5)


    Why is that?

    Code:
    qnorm ratios, rlopts(lc(black) lw(medthick)) ms(none) mc(black) connect(1) lp(dash) lc(black) ///
    addplot(scatteri 1.5 0.59, recast(line) lc(green) ///
    || scatteri 1.5 0.74, recast(line) lc(blue) ) ///
    legend(order(3 "5th centile" 4 "INew Ratio") pos(5) row(1))

    Click image for larger version

Name:	Screenshot 2023-11-03 at 13.09.57.png
Views:	1
Size:	474.9 KB
ID:	1732547


  • #2
    why not use xline, yline ?

    Comment


    • #3
      yes I've used x line and Y line but the problem is I would like the annotations of these lines to appear in the legend (5th centile, INew Ratio) rather than adjacent to the lines (this looks too busy on the graph)

      The only solutions were to use scatteri - unless of course there are other solutions you can think of

      Comment


      • #4
        you can write an function as a graph. here, a constant.

        sysuse auto, clear
        qnorm mpg , addplot(function 20 , range(0 40))
        Last edited by George Ford; 03 Nov 2023, 08:45.

        Comment


        • #5
          thanks, this creates a y line
          I would like to create 2 line at 2 different x values

          Code:
          sysuse auto, clear 
          qnorm mpg, addplot(function 20, range (0 40) horizontal) // 
          || function 10  //this produces another text value for this function in the legend - when I proceed to try plot it **see below
          
          
          //attempt 2 
          sysuse auto, clear 
          qnorm mpg, addplot(function 20, range (0 40) horizontal) // 
          || function 10 , range (10 40) horizontal 
          
          
          //this produces an error | is not a valid command name
          And how do I rename the function line appearing in the legend as 'reference'
          Last edited by Denise Vella; 03 Nov 2023, 09:09.

          Comment


          • #6
            scatteri need (y,x) start and (y,x) end.

            Code:
            qnorm mpg  ,  addplot(scatteri 0 20 40 20  , recast(line) || scatteri 20 0 20 40, recast(line) )

            Comment

            Working...
            X