Dear Stata Users,

I am producing a graph with marginsplot throug the following commands and options

svy: logit event1 ib1.tercile2##i.agesm##i.sex i.wave5 i.livingpar i.ukborn i.sex i.educ2 if marital==1&age>17&age<36&evunion ==2&jbstat!=7&ivfioall==1, or level(90)
outreg2 using model_sex_new, word label replace level(90) eform
margins i.sex#i.agesm, level(90) post atmeans dydx(tercile2)
outreg2 using margisex, level(90) replace word label

marginsplot , xdim(agesm) by(sex) ///
plot1opt(msymbol("O") msize(vlarge)) ci1opts(lwidth(medium thick) ) ///
......


When I run my mplotoffset in the following way I produce a graph without the legend (just to notice tercile2 is a bivariate variable)

marginsplot, xdim(agesm) by(sex) ///
plot1opt(msymbol("O") msize(vlarge)) ci1opts(lwidth(medium thick) ) ///
......


When I force the legend through legend(on), the legend is split into two, whereas I would like to have one single legend
(I tried to upload the file,but it kept on loading with no result. Maybe it was too heavy?)

When I put legend into by, I have an error message, which says that that operation is not allowed.

marginsplot , xdim(agesm) by(sex, legend(on)) ///
plot1opt(msymbol("O") msize(vlarge)) ci1opts(lwidth(medium thick) ) ///
......


Is there the possibility of getting what I need?

Thank you. Best,
Lydia