Announcement

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

  • Special characters in Titles, labels etc

    I'm trying to use special characters in graphs, following "Stata tip 6: Inserting awkward characters in the plot " (link)

    I can't get the output right, however. I am using Arial as a standard font for graphs. When I do below code, which has three alternatives I tried to get the dollar sign output, the title of the graph just reads exactly what I type, no replacing into dollar signs.
    I copy pasted the syntax from the above mentioned guide, but I'm still not 100% if I might be using the right (combination of) ´ ` etc. Perhaps it is a version problem? the guide mentions Stata 8, I am using 14.
    I append the data in case anyone wants to play around with it and/or see if it does works on their machine/settings.


    Secondly, I am wondering about the range of special characters. The above guide mentions ANSI codes 1 through 255. Is there perhaps an equivalent for e.g., all Unicode characters with the extended Unicode support now in Stata 14? Specifically, I was looking to use a right hand arrow (unicode 2192) in a axis label name.


    HTML Code:
    local dollarsign = char(36)
    graph bar (mean) A B C, title("Cost" "´dollarsign´" "‘=char(36)’" "‘dollarsign’")






    Attached Files

  • #2
    The problem that is biting you in this case is that you are using the wrong punctuation signs for extracting local macro contents. Without reference to your or any other dataset you should try

    Code:
    local dollarsign = char(36)
    twoway function sqrt(x), title("Cost" "`dollarsign'" "`=char(36)'")
    The left and right-hand quotation marks you need are

    Code:
    . di char(96)
    `
    
    . di char(39)
    '
    and that remains true in Stata 14 (up). The rest of that Tip written in 2004 is broken by Stata 14 insofar as it refers to characters 128 to 255. Oh well... it had some relevance for 11 years.
    Last edited by Nick Cox; 13 May 2015, 04:16.

    Comment


    • #3
      Thanks a lot for that!
      I actually also tried playing around with Chinese characters and other symbols, and then realized I have v13.1, excl. the new expanded unicode support.

      Comment

      Working...
      X