I have run on a peculiar problem with legends when adding a bar graph to a marginsplot, which does not seem identical to similar problems earlier reported with sts-graph and marginsplot. See
https://www.stata.com/statalist/archive/2011-02/msg00343.html
https://www.stata.com/statalist/arch.../msg00972.html
I have finally succeeded to graph an ordinary bar chart on top of an marginsplot (the other way around sadly does not work). I have offset the x-variable - a categorical variable - in order to not having the bar chart covering the marginsplot.
I added the legend option - and I can see it taking effect - but the resulting legend is immediately overwritten by a - quite insufficient - standard legend in the final result.
I have tried numerous different order numbers up to 9 to no avail.
Anyone who has run in a similar problem? It frankly seems like a bug.
Best regards Nino Landler, MD
.
https://www.stata.com/statalist/archive/2011-02/msg00343.html
https://www.stata.com/statalist/arch.../msg00972.html
I have finally succeeded to graph an ordinary bar chart on top of an marginsplot (the other way around sadly does not work). I have offset the x-variable - a categorical variable - in order to not having the bar chart covering the marginsplot.
I added the legend option - and I can see it taking effect - but the resulting legend is immediately overwritten by a - quite insufficient - standard legend in the final result.
I have tried numerous different order numbers up to 9 to no avail.
Code:
replace ckdgroupOffset = ckdgroup - 0.2 //The x-variable logistic diadys2 i.ckdgroup predictor variables... margins i.ckdgroup marginsplot, recast(scatter) recastci(rspike) title("Diastolic dysfunction - adjusted predictions and actual data") /// addplot(bar meandiadys ckdgroupOffset, yaxis(2) barw(0.2) xscale(range(-0.5 3.2)) xtitle("") fi(inten40) /// yscale(range(0 0.7) axis(2)) yla(0 0.1 "10" 0.2 "20" 0.3 "30" 0.4 "40" 0.5 "50" 0.6 "60" 0.7 "70", axis(2)) ytitle("%", axis(2)) /// yscale(range(0 0.7) alt) yla(0(0.1)0.7) ytitle(Probability)) legend(order(2 "DDF empirical fraction" 1 "DDF probability"))
Best regards Nino Landler, MD
.
Comment