Skip to content

Legend marker with both the dstat line and its confidence interval #7

Description

@ericmelse

Dear Ben,
Is it possible to have a legend marker with both the dstat line and its confidence interval?
Using this code:

local var pir
local vart PIR
local binary clip_in
qui sum `var'
local N = r(N)
sum `var' if `binary'==1
local Nr = r(N)
local Nrp = round((r(N)/`N')*100,.1)
sum `var' if `binary'==0
local Nx = r(N)
local Nxp = round((r(N)/`N')*100,.1)

mylabels 0(10)100, local(myxlab) myscale(@/100) suffix("%")
dstat density `var' , over(`binary') n(200) k(e) ll(0) ul(1) unconditional /// if `constraint'
	gr(aspect(1) xsize(8) ysize(8) graphreg(fc(white) ilc(white) lc(white) m(l-2 r-0 b-0 t-0)) ///
	xsc(noex) xlab(`myxlab', labs(*.8) ) ylab(0(.1)2, labs(*.7) angle(none) nogrid) ///
	p1(lc(stred) ciopts(color(stred%20))) ///
	p2(lc(stblue) ciopts(color(stblue%20))) ///
	xtitle("Person isotonic R² (PIR)", m(l+1 r-1 t+1 b-1)) ytitle("Density (Epanechnikov kernel function)", m(t+1 b-1)) ///
	legend(order(2 "95% CI" 4 "Retained" "n=`Nr', `Nrp'%" 1 "95% CI" 3 "Excluded" "n=`Nx', `Nxp'%") ///
	region(c(none)) size(*.7) col(1) pos(11) rowgap(0) ring(0)) ///
	ysc(range(0 2) noex) ylabel(0(.1)2) flip name(HHdstatPIRclip, replace)) 

The result plot is:
Image
But, what I am trying to get is:
Image
Perhaps this is not possible, but if it is, time permitting, I really appreciate your helping hand,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions