Announcement

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

  • Marginsplot legend labeling with plotopts

    Dear all,

    I'm want to plot an an interaction effect, with labels in the legend. Thus, I'm using this code:
    Code:
        margins, at(cfo_fin_acc_l1=(0(1)1) cfo_age_w_l1=(38(9)65)) vsquish
         marginsplot, plot1opts(msymbol(O )) plot2opts(msymbol( D )) plot3opts(msymbol( T )) plot4opts(msymbol( S))  saving("Margins_CFO_Fin_Acc", replace) legend(order(1 "CFO Age = 38" 2 "CFO Age = 47" 3 "CFO Age = 56" 4 "CFO Age = 65"))
    Which leads to the following Graph:

    Click image for larger version

Name:	Margins_CFO_Fin_Acc.png
Views:	1
Size:	43.2 KB
ID:	1684504

    Although the labels are now displayed in the legend, the plot options are no longer displayed in the legend, as it was the case in the default version without the legend-option (The symbol of the marker is missing): Click image for larger version

Name:	InkedMargins_CFO_Fin_Acc_2.jpg
Views:	1
Size:	73.1 KB
ID:	1684503

    I was wondering if there is an option to display the label with the marker symbol in the legend? (e.g., a blue line with an O and the label " CFO Age = 38")
    All options (mlabel, legend(label()),...) that I tried, did not work.

    Thanks in advance!

    Kind regards,
    Marius Meyerhoff
    Last edited by Marius Meyerhoff; 05 Oct 2022, 18:07.

  • #2
    The lines with markers should most likely start at #5. So try

    Code:
    legend(order(5 "CFO Age = 38" 6 "CFO Age = 47" 7 "CFO Age = 56" 8 "CFO Age = 65"))
    instead.

    Comment


    • #3
      It worked!
      Sometimes the solution is very simple (if you know how to do it)...

      Thank you, Andrew!

      Comment

      Working...
      X