Hello Statalist,
I would like to add text to a marginsplot with by groups and could not find an option to add different text based on the by group. Here is an example of code to add the text "p-value" to the graphs but what I would like to do is to add the actual p-values to each graph which would be different for girls and boys. Worst case scenario, I can manually do this with the Graph Editor but would ideally like to be able to automate it.

I would like to add text to a marginsplot with by groups and could not find an option to add different text based on the by group. Here is an example of code to add the text "p-value" to the graphs but what I would like to do is to add the actual p-values to each graph which would be different for girls and boys. Worst case scenario, I can manually do this with the Graph Editor but would ideally like to be able to automate it.
Code:
use "http://www.bristol.ac.uk/cmm/media/runmlwin/tutorial.dta", clear
regress standlrt i.girl i.schav
margins girl#schav
marginsplot, by(girl) recast(scatter) scheme(s1mono) byopt(title(" ")) ///
text(0.4 1.5 "p-value = ", placement(w))

Comment