Announcement

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

  • line feed in graph label

    I am adding a line feed to a label to be printed below the others on the x axis
    the graph shows, saves, and exports fine, but tempting to use it with graph combine results in an error ("invalid something: quotes do not match", or "too few quotes"), see example below
    Of course this practice is unorthodox, and I could export it as TIFF and combine with other graphs using ImageMagick or other tools, but I wonder if there is a way to trick also graph combine
    I am using StataNow19.5 in Windows
    thanks!
    Code:
    sysuse auto, clear
    gen category= foreign+2*(weight>2500)
    local lf=char(10)
    scatter mpg category, xla(0 "Light" .5 "`lf'Domestic" 1 "Heavy" 2 "Light" 2.5"`lf'Foreign" 3 "Heavy", notick) xtick(0(1)3) xtitle("") name(linefeed, replace)
    
    graph combine linefeed

  • #2
    You cannot use an unconventional approach and then ask for help when you run into trouble. There is no need to use char(10) as a line break here, which would, incidentally, only work on a Windows system. What you want can be achieved using the -text()- option.

    Code:
    sysuse auto, clear
    gen category= foreign+2*(weight>2500)
    local lf=char(10)
    scatter mpg category, xla(0 "Light" 1 "Heavy" 2 "Light" 3 "Heavy", notick) xtick(0(1)3) ///
    xtitle("") text(5.75 0.5 "Domestic"  5.75 2.5 "Foreign") name(linefeed, replace)
    graph combine linefeed
    Click image for larger version

Name:	Graph.png
Views:	1
Size:	22.1 KB
ID:	1781660

    Comment

    Working...
    X