Announcement

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

  • Annotating a line in a graph, lines dashed/bold in scatter plot

    Hello I've got this graph produced with this code

    Code:
    qnorm neonates, jitter(6) xline(1.2 1.12 0.59 0.74, lwidth(1) lstyle(grid) lcolor(gs12))
    How can I annoate all the 4 xlines with a legend + is is possible to give them separate colors?
    When I manually use the graph editor and change the colour/ choose solid or dashed for one line, the changes are applied to all the lines..


    The first two x lines - would be blue (one bold and one dashed) - labelled as 95th centile as per Carr, 95th centile in local population
    The second two x lines - would be red (one bold and one dashed) - labelled as 5th centile as per Carr, 5th centile in local population

    I tried to manually annote the lines but I think this involves too much head twisting and makes more sense to add a legend with dashed/solid lines


    Attached Files
    Last edited by Rose Matthews; 02 Oct 2023, 23:40.

  • #2
    You can have multiple -xline()-s.

    Code:
    sysuse auto, clear
    set scheme s1color
    qnorm weight, xline(2500, lc(red) lp(dash) lw(medthick)) xline(4500, lc(blue) lw(medthick))
    Res.:

    Click image for larger version

Name:	Graph.png
Views:	1
Size:	31.3 KB
ID:	1728889

    Comment


    • #3
      As in your earlier thread https://www.statalist.org/forums/for...l-shaped-curve (please note my reply at #14) also, I recommend strongly against jittering quantile plots. You can choose very small marker symbols or use some quite different graph if ties are a problem but it's my strong guess that jittering on quantile plots would be regarded by competent reviewers, examiners or editors as somewhere between puzzling at best and utterly wrong at worst.

      Comment


      • #4
        Hi Nick,
        Yes I read and re-read your post.
        How with regards to the graph here, is there anything else you would recommend related to the earlier thread you kindly linked in post3
        apart from not using jitter?

        Comment


        • #5
          Sorry, but I am getting confused by the many threads you are running, some of which seem to overlap.

          But Andrew Musau's #2 seems a fine answer in this thread. But I know that #2 is an example with 74 observations. If you have many more, some refinement of technique may be needed.

          Comment


          • #6
            I don't want to confused people further, but if I may ask another question - how do I insert a legend?

            Code:
            qnorm insall, xline(1.12, lc(red) lp(dash) lw(medthick)) xline(1.2, lc(red) lw(medthick)) xline(0.74, lc(blue) lp(dash) lw(medthick)) xline(0.59, lc(blue) lw(medthick)) 
            
            legend(pos(3) region(lstyle(dash)) lstyle(solid)) /// I used the stata help for this section but of course it's not working, can you please let me know what I'm missing out.
            Key:
            Dash = Local population
            Solid = Expected population

            Comment


            • #7
              The legend of qnorm is by default off. If you want to see one you need to reverse that with legend(on) together with whatever options. I agree with the programmers of qnorm: a legend is not needed for your case, but you can over-ride that choice.

              If you think your readers are new to the idea, explaining in a caption or surrounding text is a good way to meet that problem.

              Comment

              Working...
              X