Announcement

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

  • Twoway scatter: invalid 'mlabels', but only after adding graph options

    I am trying to run a boxplot graph, using scatter to add value labels to the median point. The code runs fin (and gives me the desired result, complete with labels) until I add the , graph options for labelling etc, at which point I get the newly-ecountered error message "invalid 'mlabels'". I have tried moving the separator comma to the end of the previous line, tried with and without gaps etc, but can't get it to run. Secondary issue: in earlier versions of the graph, it was also not truncating the xscale at 4.5 as requested, but running out to 5. Can anyone help me spot the error? Code and small sample od data below. Thanks.

    Code:
    twoway ///
    rbar p25 med offset if ecat == 1, barw(.2) color(dkgreen) || ///
    rbar med p75 offset if ecat == 1, barw(.2) color(eltgreen) || ///
    rbar p25 med offset if ecat == 0, barw(.2) color(red) || ///
    rbar med p75 offset if ecat == 0, barw(.2) color(red*0.5) || ///
    scatter med offset_lab if ecat==1, msymbol(none) mlabel(medlabel_str) mlabcolor(green) mlabposition(3) mlabsize(vsmall) || ///
    scatter med offset_lab if ecat==0, msymbol(none) mlabel(medlabel_str) mlabcolor(red) mlabposition(3) mlabsize(vsmall) ///
    , ylabel(#5, axis(1) labsize(small) format(%3.0fc) angle(0)) ///
    title("Persen selisi harga $graph_nmeds obat studi per fase pengadaan ecatalog dan manual""dibandingkan dengan harga swasta ekatalog di fase yang sama", size(small)) ///
    xtitle("Fase pengadaan ecatalog") ///
    xlabel(2 "Ecatalog 2021-2022" 3 "Obatpedia" 4 "Obatpedia + konsolidasi", labsize(vsmall) noticks) xscale(range(1.5 4.5)) ///
    subtitle("$graph_nfaskes faskes mitra PROmeds", size(vsmall)) ///
    legend(off) ///
    plotregion(lstyle(none))
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input byte(ecat phase) double(offset p25 p75 med) str4 medlabel_str double(offset_lab phase_lab)
    0 2 2.25 -4.028416300538851e-06 115.10749354005169 18.242105263157903 "18.2" 2.33 2
    0 2 2.25 -4.028416300538851e-06 115.10749354005169 18.242105263157903 "18.2" 2.33 2
    0 2 2.25 -4.028416300538851e-06 115.10749354005169 18.242105263157903 "18.2" 2.33 2
    0 2 2.25 -4.028416300538851e-06 115.10749354005169 18.242105263157903 "18.2" 2.33 2
    0 2 2.25 -4.028416300538851e-06 115.10749354005169 18.242105263157903 "18.2" 2.33 2
    0 2 2.25 -4.028416300538851e-06 115.10749354005169 18.242105263157903 "18.2" 2.33 2
    0 2 2.25 -4.028416300538851e-06 115.10749354005169 18.242105263157903 "18.2" 2.33 2
    0 2 2.25 -4.028416300538851e-06 115.10749354005169 18.242105263157903 "18.2" 2.33 2
    0 2 2.25 -4.028416300538851e-06 115.10749354005169 18.242105263157903 "18.2" 2.33 2
    0 2 2.25 -4.028416300538851e-06 115.10749354005169 18.242105263157903 "18.2" 2.33 2
    0 2 2.25 -4.028416300538851e-06 115.10749354005169 18.242105263157903 "18.2" 2.33 2
    0 2 2.25 -4.028416300538851e-06 115.10749354005169 18.242105263157903 "18.2" 2.33 2
    0 2 2.25 -4.028416300538851e-06 115.10749354005169 18.242105263157903 "18.2" 2.33 2
    0 2 2.25 -4.028416300538851e-06 115.10749354005169 18.242105263157903 "18.2" 2.33 2
    0 2 2.25 -4.028416300538851e-06 115.10749354005169 18.242105263157903 "18.2" 2.33 2
    0 2 2.25 -4.028416300538851e-06 115.10749354005169 18.242105263157903 "18.2" 2.33 2
    0 2 2.25 -4.028416300538851e-06 115.10749354005169 18.242105263157903 "18.2" 2.33 2
    0 2 2.25 -4.028416300538851e-06 115.10749354005169 18.242105263157903 "18.2" 2.33 2
    0 2 2.25 -4.028416300538851e-06 115.10749354005169 18.242105263157903 "18.2" 2.33 2
    0 2 2.25 -4.028416300538851e-06 115.10749354005169 18.242105263157903 "18.2" 2.33 2
    end
    label values phase phase
    label def phase 2 "2 Ecatlog 2021-22", modify
    label values phase_lab phase_lab
    label def phase_lab 2 "Ecatalog 2021-2022", modify
    Last edited by Elizabeth Pisani; 29 May 2026, 03:16.

  • #2
    Have you got one comma too many? I don't think there should be a comma before the ylabel() call.

    Comment

    Working...
    X