Announcement

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

  • Add a line break in a legend text

    Hi all,
    I need to break a legend text in two lines for a better fit to the graph.
    I am using the sts graph command, and I followed the advice given to break text lines in labels, but it doesn't seem to work with the legend option.

    My line of code is the following:
    Code:
        legend(order(1 "Epithelioid hemangioma" 2 `" "Pseudomyogenic" "hemangioendothelioma" "' 3 "Hemangioendothelioma" 4 "Angiosarcoma") cols(1) pos(3) ring(1) symxsize(*.5))
    and what I get for key n.2 is a single line of text including "Pseudomyogenic" "hemangioendothelioma" with one space at the beginning and at the end. That is, all which is included within the compound quotes.

    Any suggestion?

    thanks a lot

  • #2
    Compound quotes are not needed.
    Code:
    sysuse auto
    twoway (scatter mpg weight if foreign==0) (scatter mpg weight if foreign==1), ///
      legend(label(1 "Line 1" "Line 2") label(2 "Line 1" "Line 2"))

    Comment


    • #3
      Thank you Friedrich!
      I was aware of and I tried the formulation without compound quotes, but my problem was that I used the order option instead of label...
      So your answer was helpful indeed

      best regards

      Comment

      Working...
      X