Announcement

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

  • xlabels have problems with the minus character

    I need to label the ticks on the x axis on a plot with another number than the real x number on the axis.

    If those labels are negative numbers that start with a minus, a sort of syntax error is returned.

    In particular, I was trying the following:
    Code:
    estat trendplots, nocommonlegend title("H${hp}") xtitle("Year") ytitle("Similarity") xlabel(0 "-5" 1 "-4" 2 "-3" 3 "-2" 4 "-1" 5 "0" 6 "1" 7 "2" 8 "3" 9 "4" 10 "5", angle(90))
    and it returns an error:
    Code:
    5" 1 " invalid name
    r(198);
    If I replace the minus character (U+002D) with another character which is visually similar to minus, for example with figure dash (U+2012), it works correctly:
    Code:
    . estat trendplots, nocommonlegend title("H${hp}") xtitle("Year") ytitle("Similarity") xlabel(0 "‒5" 1 "‒4" 2 "‒3" 3 "‒2" 4 "‒1" 5 "0" 6 "1" 7 "2" 8 "3" 9 "4" 10 "5", angle(90))
    What's the problem with the minus character?
    Last edited by Giuseppe Polito; 22 Feb 2023, 03:51.

  • #2
    I have never tried anything like that, but I note that this works

    Code:
    . twoway function equality=x, ra(-2 2) yla(-2 "{&minus}2" -1 "{&minus}1" 0 1 2, ang(h))

    Comment


    • #3
      Ok thanks.

      Why with the real minus character it doesn't work?

      Comment


      • #4
        Why the original didn't work I can't tell you. You could take it up with StataCorp technical support.

        Comment


        • #5
          Originally posted by Nick Cox View Post
          Why the original didn't work I can't tell you. You could take it up with StataCorp technical support.
          Where do I find their contact?

          Don't they read this forum?

          Comment


          • #6
            Where do I find their contact?
            [email protected]. When you write them, you should include the output on your computer from running the -about- command, and a good description of the computer and OS you are running on. And then give them example data and code that reproduce the problem you are having, and explain the nature of the problem you are having..


            Don't they read this forum?
            There are people at StataCorp who read this forum, but not necessarily the people in Tech Support. Only a very small fraction of the problems presented in this Forum turn out to be due to bugs--so it wouldn't be a very productive use of their time to read everything here.

            Comment


            • #7
              It looks like the problem is limited to -estat trendplots-. The negative labels work in other graph commands. For example:

              Code:
               
              webuse auto, clear
              
              scatter mpg rep78, ///
              xlabel(0 "-5" 1 "-4" 2 "-3" 3 "-2" 4 "-1" 5 "0", angle(90))
              I will submit this as a bug. In the meantime, Nick's smcl workaround should work.

              Comment


              • #8
                Thanks

                Comment


                • #9
                  Until this discussion it never occurred to me that smcl directives might also work in contexts like marker labels in twoway scatter, for example. It turns out they do. Perhaps this is widely known but it was not known to me.

                  This is a silly example but it gets the point across:

                  Code:
                  drop _all
                  sysuse auto
                  gen ml1="obs{sub:"+strofreal(_n)+"}"
                  gen ml2="{bf:obs}"+strofreal(_n)
                  
                  list price mpg ml1 ml2 in 1/10
                  
                  scatter price mpg, mlab(ml1)
                  scatter price mpg, mlab(ml2)

                  Comment


                  • #10
                    Turn and turn about, this thread led me to check whether aaplot from SSC supports display of minus characters, rather than hyphens masquerading as such. It does now, in a minute (minus?) update which will be announced under the appropriate thread.

                    Comment

                    Working...
                    X