Announcement

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

  • Legend in marginsplot

    I am attempting to produce a graph using marginsplot for a categorical variable with three categories. When marginsplot produces the graph, however, the values are listed in the legend instead of the value labels. I attempted to correct this with the syntax in the last line of code below, but no luck:

    margins, dydx(lender) at(MinPopPerc = (0 (5) 100))
    marginsplot, yline(0) ///
    title ("Difference in Predicted Probability of Approving Loan by Tract Racial Composition & Lender", size(small)) ///
    subtitle ("Controlling for income, loan amount, year, sex, tract % minority", size(Small)) ///
    ytitle ("Difference in Probability of Approval compared to SFCU") ///
    xtitle ("Percent Minority in Tract", size(vsmall)) ///
    caption ("Source: 2010-2014 HMDA data") ///
    legend (label(2 "Comparison Lenders") label(3 "Other Lenders"))

    Can anyone suggest a solution?
    I did not see this elsewhere, I apologize if I overlooked an answer to this question.

  • #2
    Two solutions are provided here:

    http://www.stata.com/statalist/archi.../msg00171.html


    Code:
    *EITHER 
    marginsplot, plot( , label("Comparison Lenders" "Other Lenders"))
    
    *OR
    marginsplot, legend(order(2 "Comparison Lenders" 3 "Other Lenders"))

    Comment

    Working...
    X