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

  • Long legend text from labels

    Humbly trying out this forum for the first time, hoping to learn from you smart, helpfull people

    My problem is that half the text from my labels disappear:

    I use the graph bar command to generate stacked bars to show the distribution of categorized data (11 categories - variabel "akt_kat") from 21 individual people (variabel "person")

    .graph bar, over(akt_kat) over(person, label(angle(90))) asyvars percentage stack ///
    .legend(region(lstyle(none))title("Kategori", size (*1.0)) ) ///
    .ytitle("Procent") ///
    .b1title("Person") ///
    .xsize(5.5) ysize (5) scale(0.5) name(g1,replace)

    Only half the label text is shown in the legend.
    The label text contain up to 65 letters.

    I tried setting textwidth to (*8) and (70), but there was no change in the visual output

    I tried finding the answer myself, but officially give up now.
    Thank you in advance,

  • #2
    The most direct way would be to use the relabel() suboption with the over() option. See also:

    sysuse nlsw88, clear
    label define racelbl 1 "This is a very very very long value label" 2 "black" 3 "other", replace
    graph bar,  over(race, relabel(1 `""This is a very very" "very long value label""'))   /// 
        over(smsa) stack  asyvars percentage
    Click image for larger version

Name:	Graph2.png
Views:	1
Size:	20.5 KB
ID:	1453356