Announcement

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

  • ylabel containing apostrophes overlap with ytitle

    Hi

    When I use an apostrophe in the ylabel the ytitlegap is not correctly specified.
    I used the margin option to set the gap.
    However, I wonder if there is an other way to define the ylabel to avoid this problem?

    I'm using Stata 13.1


    Code:
    clear
    sysuse auto
    
    * problem
    tw scatter price price, scheme(s2color) ///
    ylabel(0 "0" 5000 "5'000" 10000 "10'000" 15000 "15'000", angle(horizontal))
    
    * no problem
    tw scatter price price, scheme( s2color) ///
    ylabel(0 "0" 5000 "5.000" 10000 "10.000" 15000 "15.000", angle(horizontal))
    
    * quick fix
    tw scatter price price, scheme(s2color)  ///
    ylabel(0 "0" 5000 "5'000" 10000 "10'000" 15000 "15'000",  angle(horizontal)) ///
    ytitle(, margin(0 12 0 0))
    Last edited by Barbara Fischer; 27 Sep 2016, 05:35.

  • #2
    Consider the suboption

    Code:
    ysc(titlegap())
    for changing the space between axis and title. In your example, 15 seems about right.

    Comment


    • #3
      Thanks, ysx(titlegap()) works fine.
      Is used the following code to make it a bit more flexible:

      Code:
      qui su price
      
      local titlegap `"`=length("`=max(abs(`r(max)'),abs(`r(min)'))'")*2.5'"'
      
      tw scatter price price, scheme(s2color)  ///
      ylabel(0 "0" 5000 "5'000" 10000 "10'000" 15000 "15'000",  angle(horizontal)) ///
      ysc(titlegap(`titlegap'))
      Neverthless, I would be nice if the graph command would recognize the string and use the correct titlegap.

      Comment


      • #4
        I'd change the units here (in this example, divide by 1000), but that's a matter of taste. (Presumably the example is proxy for your real example.)

        Comment

        Working...
        X