Announcement

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

  • Change legend position in distplot (from SSC) when using 'over'?

    How do I change the legend position in distplot (from SSC) when using the option 'over'?


    distplot Ferritin, over(no_meat) ylabel(0(.1)1) xlabel(0(10)100) by(BMI_cat_fewer) legend(pos(6))

  • #2
    distplot is to be cited please as coming from the Stata Journal. (My fault if you like that I don't maintain the SSC version assiduously.)

    More interestingly, the main issue with your syntax is using by() as well as over().

    We can't see your data or your graph, but you might get nearer to what you want with something like

    Code:
    distplot Ferritin, over(no_meat) ylabel(0(.1)1) xlabel(0(10)100) by(BMI_cat_fewer, legend(pos(6)))

    Comment


    • #3
      I am so sorry about that. I am still new and learning to use the terms correctly. Thank you for correcting me!

      This is my full code:
      *By and over.
      distplot Ferritin if Ferritin < 100, over(Food_last_year_no_meat) ylabel(0(.1)1) xlabel(0(10)100) by(BMI_cat_fewer) legend(pos(6))

      And this is my graph. Adding the comma before legend does not produce any output. Is there any way to work around it?

      Click image for larger version

Name:	Graph legend.jpg
Views:	1
Size:	45.6 KB
ID:	1743682

      Comment


      • #4
        The call to legend() must be inside the call to by(). See #2 again.

        Comment

        Working...
        X