Announcement

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

  • dpplot is not a twoway plot type

    Hi!
    I'm using dpplot in Stata 18 from ssc. I am generating 5 different dpplots and wanted to display them in a single graph with each pdf having a different color and identify them in the legend. However, the error message says "dpplot is not a twoway plot type". Is there any way around this?
    Thanks

  • #2
    For anyone wondering, this is apparently as good as it gets:

    forvalues i=1/5 {
    sum var if category==`i'
    local m`i' = r(mean)
    local SD`i' = r(sd)
    local min`i' = r(min)
    local max`i' = r(max)
    }

    twoway function var = normalden(x, `m1', `SD1'), ra(`min1' `max1') || ///
    function var = normalden(x, `m2', `SD2'), ra(`min2' `max2') || ///
    function var = normalden(x, `m3', `SD3'), ra(`min3' `max3') || ///
    function var = normalden(x, `m4', `SD4'), ra(`min4' `max4') || ///
    function var = normalden(x, `m5', `SD5'), ra(`min5' `max5') ///
    legend( position(6) cols(5)) ytitle(Density)

    Comment

    Working...
    X