Announcement

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

  • Unable to change x label on marginsplot

    Hello!

    I have been attempting to change the x labels on my marginsplot, but have been unable to do so. I have used both
    Code:
    legend(order
    and
    Code:
    plot(, label
    but neither seem to work. Please could someone point me in the right direction, or let me know if I'm making a silly mistake (wouldn't be my first!).

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input byte(foreignaid education lrscale age income authoritarian tax)
    0 0  3 21 1  0  7
    1 1  0 53 1  0 10
    1 0  5 56 1  5  8
    0 0  6 65 3  0  5
    0 4  2 68 3  0  8
    0 5  4 34 .  5  7
    0 0  7 83 .  0 10
    1 0  5 66 .  0  5
    1 0  6 66 1  0  5
    1 3  . 42 4  5  5
    1 3  5 58 3  0  5
    1 4  5 24 3  5 10
    1 2  4 78 3  0  5
    1 4  6 45 4  0  7
    1 0 10 93 2  0  6
    1 1  5 34 3  6  5
    1 2 10 23 2  5  5
    1 3  5 27 3  0  7
    0 4  0 36 3  5  5
    0 4  5 40 4  0  8
    0 5  5 44 3  0  8
    1 3  5 51 3  4  5
    1 4  4 65 1  3  8
    1 2  5 64 .  8  8
    0 3  2 55 3  3  8
    1 1  0 57 1  5 10
    1 4  7 27 4  6  8
    1 4  4 35 4  2  7
    1 4  4 66 3  8  6
    1 4  6 62 3  8  8
    1 4  7 56 3  5  3
    0 0  5 67 .  0 10
    1 4  7 49 4  2  7
    1 4  5 43 4  3  6
    0 4  2 59 .  3 10
    1 4  7 80 4  3  5
    1 3  7 36 4  7  8
    0 0  . 71 4  1  8
    1 0  5 80 1  5  8
    0 4  3 60 .  3  7
    1 4  5 44 .  1  7
    0 4  6 69 1  0  8
    0 0  4 65 4  6  7
    1 4  9 62 4  1  4
    0 4  6 40 1  5  4
    0 5  . 30 3  0 10
    0 0  . 19 .  8 10
    1 1  6 51 3  4  7
    0 2  5 88 1  7 10
    1 0  . 68 .  7  7
    1 0  . 82 .  .  5
    1 4  7 45 3  3  5
    0 3  2 64 2  3  7
    0 5  5 60 4  3  5
    0 2  5 47 3  4  6
    0 2  5 60 .  3  7
    0 4  6 53 3  4  5
    0 5  3 51 3  5  7
    1 0  . 34 .  0 10
    1 0  . 34 3  0  5
    0 2  8 38 4  0  5
    0 5  5 44 3  5  0
    0 2  7 20 .  0  5
    0 4  . 21 3  2  7
    1 0  5 75 2  8 10
    1 5  5 42 4  7  8
    1 3  5 68 .  0 10
    1 4  4 62 .  3  8
    1 4  . 62 .  0  9
    1 0  .  . .  5  .
    1 0 10 78 2  2  9
    0 0  2 54 3  2  7
    1 2  . 55 4  0 10
    1 0  . 61 .  8 10
    0 5  3 58 4  2  9
    0 1  1 41 3 10 10
    0 4  6 53 .  5  5
    0 2  2 28 .  4 10
    1 4  6 34 1  0  5
    1 0 10 82 2  0  7
    1 4  6 46 .  0 10
    1 0  7 94 1  7 10
    0 0 10 63 3  0  9
    1 2  . 50 3  0 10
    0 0  . 68 3  0  5
    0 4  4 24 4  7  4
    0 3  2 26 3 10  9
    1 0  5 57 3 10  8
    1 3  5 64 1  6  5
    1 0  4 53 4  8  9
    0 1  5 71 1  2  8
    1 0  8 71 2  4  9
    1 0  . 89 .  0 10
    0 3  3 57 .  1 10
    1 2  5 64 1  8 10
    1 4  . 80 1  3  8
    1 0  5 80 .  1 10
    1 1  . 79 1  . 10
    0 4  2 67 3  7  8
    1 0  5 57 .  0  7
    end
    label values foreignaid foreignaidl
    label def foreignaidl 0 "0. Other responses", modify
    label def foreignaidl 1 "1. Reduce foreign aid", modify
    label values education edlevel
    label def edlevel 0 "0. No qualifications", modify
    label def edlevel 1 "1. Below GCSE", modify
    label def edlevel 2 "2. GCSE", modify
    label def edlevel 3 "3. A-level", modify
    label def edlevel 4 "4. Undergraduate", modify
    label def edlevel 5 "5. Postgrad", modify
    label values lrscale lrscalel
    label def lrscalel 0 "0. Left", modify
    label def lrscalel 10 "10. Right", modify
    label values income incomel
    label def incomel 1 "1. Low income", modify
    label def incomel 2 "2. Below median income", modify
    label def incomel 3 "3. Above median income", modify
    label def incomel 4 "4. High income", modify
    label values authoritarian authoritarianl
    label def authoritarianl 0 "0. Fight terrorism", modify
    label def authoritarianl 10 "10. Protect civil liberties", modify
    label values tax taxl
    label def taxl 0 "Government should cut taxes a lot", modify
    label def taxl 10 "Government should increase taxes", modify
    Logistic regression and margins:

    Code:
    logit foreignaid i.education lrscale age i.income authoritarian tax
    Code:
    quietly margins, at(tax=(0/10))
    Attempt 1 to change x label using legend in margins plot:

    Code:
    marginsplot, ///
    recast(line) ///
    ciopt(color(%20)) ///
    recastci(rarea) ///
    xlabel(, labsize(vsmall) angle(45)) ///
    xtitle("Tax Spend", ///
    size(small)) ///
    ytitle("Probability of supporting a reduction in foreign aid", ///
    size(small)) ///
    title("    ") ///
    caption("APMs (with 95% CIs)", ///
    size(vsmall)) ///
    legend(order(0 "Cut taxes" 10 "Increase taxes"))
    Attempt 2 to change x label using plot label in margins plot:

    Code:
    marginsplot, ///
    plot(, label("Cut taxes" "Increase taxes")) ///
    recast(line) ///
    ciopt(color(%20)) ///
    recastci(rarea) ///
    xlabel(, labsize(vsmall) angle(45)) ///
    xtitle("Tax Spend", ///
    size(small)) ///
    ytitle("Probability of supporting a reduction in foreign aid", ///
    size(small)) ///
    title("    ") ///
    caption("APMs (with 95% CIs)", ///
    size(vsmall))

  • #2
    Why would changing the x-axis label involve the -legend()- option or any other option other than -xlabel()-?

    Code:
    xlabel(0 "Cut taxes" 1/9 10 "Increase taxes")

    Comment


    • #3
      Hi Andrew

      Sorry about the silly question - just tried your code and it worked. Thank you very much for your help!

      Comment

      Working...
      X