Announcement

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

  • Line break xlabel

    Hey!

    I want to make a line break in my xlabels. However, I always get the error message "in range not allowed - r(101)". What is wrong with the following code in the xlabel part?

    Code:
     #delimit ;
    twoway rcap high low x  || scatter mean x, mcolor(black) msize(small) legend(off)
    xlabel(1 ‘" "PGM activity" "in previous conflict" "’ 2 ‘" "no PGM activity" "in previous conflict" "’, labsize(small))
    xscale(range(0 3))
    ylabel(0 "0%" 0.2 "20%" 0.4 "40%" 0.6 "60%" 0.8 "80%")
    xtitle("")
    scheme(s1mono)
    note("Source: Created by the author based on statistical simulation technique (introduced by King et al. 2000)")
    title("Graph 2: Simulated probabilities of post-conflict relapse")
    ytitle("Expected likelihood of conflict resurgence")
    name(graphx, replace);
    #delimit cr

  • #2
    I'm not sure what type of editor (or keyboard) you are using, but whatever it is, it is incorrectly representing the left single quote and right single quote that Stata needs (see help quotes). Stata's own editor (type doedit to launch) has syntax highlighting that helps to spot those errors.

    This works:
    Code:
    #delimit ;
    twoway rcap high low x  || scatter mean x, mcolor(black) msize(small) legend(off)
    xlabel(1 `" "PGM activity" "in previous conflict" "' 2 `" "no PGM activity" "in previous conflict" "', labsize(small))
    xscale(range(0 3))
    ylabel(0 "0%" 0.2 "20%" 0.4 "40%" 0.6 "60%" 0.8 "80%")
    xtitle("")
    scheme(s1mono)
    note("Source: Created by the author based on statistical simulation technique (introduced by King et al. 2000)")
    title("Graph 2: Simulated probabilities of post-conflict relapse")
    ytitle("Expected likelihood of conflict resurgence")
    name(graphx, replace);
    #delimit cr
    This does not:
    Code:
    " "PGM activity" "in previous conflict" " 2 " "no PGM activity" "in previous conflict" "
    Stata/MP 14.1 (64-bit x86-64)
    Revision 19 May 2016
    Win 8.1

    Comment


    • #3
      Thanks for the response! Unfortunately, it also doesn't work when I copy your code. I receive the same error message. Maybe this sign is not accepted by my Stata version (14.1)? Is it possible to solve this with the gaph editor?

      Comment


      • #4
        This code runs perfectly in Stata 14.1 & Stata 13.1 There is something weird with your copy & paste function (automatically turning the quotes into curly quotes) or the way that your browser is rendering the characters.

        Copy the code into the Stata do-file editor.
        Replace the single left quotes with with the grave accent (on US keyboards, that's the one at the top left key next to number 1.
        Replace the single right quote with the apostrophe (on US keyboards that's the one next to the enter key).
        If you are using a different keyboard, read help quotes.

        This is pretty important to get working correctly as advanced use of Stata requires extensive use of these characters.
        Stata/MP 14.1 (64-bit x86-64)
        Revision 19 May 2016
        Win 8.1

        Comment


        • #5
          Carole is right as usual. In Stata 14.1 the left and right single quote characters are as displayed here:

          Code:
          . di uchar(96)
          `
          
          . di uchar(39)
          '
          . about
          
          Stata/SE 14.1 for Windows (64-bit x86-64)
          Revision 30 Mar 2016
          The right single quote belongs on the right, i.e. at the end, of a local macro reference, but in Stata it displays as an upright character, i.e. not leaning to the right,

          Comment


          • #6
            Thanks a lot for your help! With all this advice it works now!

            Comment

            Working...
            X