Announcement

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

  • Add vertical line to kdensity plot

    Hi, I'm trying to overlay two densities and then draw a vertical line at the mean for pop2. I'm getting the density part fine, but can't figure out how to add a line. I was trying to use xline() but it seems as if that doesn't work with kdensity. My code (without all the titles and formatting) is just this:

    Code:
    kdensity pop1, addplot(kdensity pop2)

  • #2
    I am not sure what you meant by "doesn't work with kdensity" (pasting the actual error from Stata would have been helpful). I used this and it seems fine:

    Code:
    kdensity v1, addplot(kdensity v2, xline(0))

    Comment


    • #3
      Oh shoot, I just had my syntax wrong--I put the xline after the addplot(). In reading some other examples I thought I interpreted them as saying xline() should only work with twoway. Thank you.

      Comment


      • #4

        Code:
        kdensity v1, addplot(kdensity v2) xline(0)
        should work too.

        Comment

        Working...
        X