Announcement

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

  • Twoway Graph - option mlabformat() not allowed

    Hi everyone,

    First time posting questions by myself here. I used to browse the questions and find solutions accordingly, which is very helpful.

    First of all, I am using Stata 14, which might be a little bit old. As for my question, I encountered an error message telling me "option mlabformat() not allowed r(198)" when formatting my two-way graph. I would like to label the scatter plot within the two-way graph and only keep two decimal points regarding the label. However, the software won't let me do so by using mlabformat function. Is there any way of getting around this problem? I wonder if it is because twoway function does not accept mlabformat.


    Code:
    twoway (bar freq_scale scaleport if portfolio == 0, bcolor(ltblue) yaxis(1) ytitle("Number of Hotel Transactions")) ///
    (bar freq_scale scaleport if portfolio == 1, bcolor(navy) yaxis(1))///
    (line pc_scale scaleport if portfolio == 1, lcolor(black) yaxis(2) ytitle("Percent of Hotels within Portfolios(%)", axis(2))) ///
    (scatter pc_scale scaleport if portfolio == 1, mlabel(pc_scale) mlabposition(12) mlabformat(%9.2f) mcolor(black) msize(small) mlabcolor(black) yaxis(2)), ///
    legend(row(3) order(1 "number of hotel transactions" 2 "number of hotel transactions within portfolios" 3 "percentage of hotel transactions within portfolios")) ///
    xlabel(1.5 "Economy" 4.5 "Midscale" 7.5 "Upper Midscale" 10.5 "Upscale" 13.5 "Upper Upscale" 16.5 "Luxury" 19.5 "Independent", angle(45) noticks) ///
    xtitle("Scale")
    Thank you so much!

    Best,
    Atlas
    Last edited by Atlas Wu; 07 Sep 2021, 20:47.

  • #2
    As Stata tells you, mlabformat() is an option, not a function. I don't have access any longer to Stata 14, but see if


    Code:
    help marker label options
    mentions mlabformat() in your Stata. If it does not then presumably you need something like

    Code:
    gen mylabel = string(pc_scale, "%3.2f")
    and then feed that to mlabel();

    NOTE I do have access, as does almost anyone, to https://www.stata.com/manuals14/g.pdf which indicates that the option had not yet been introduced.
    Last edited by Nick Cox; 08 Sep 2021, 03:47.

    Comment


    • #3
      Originally posted by Nick Cox View Post
      As Stata tells you, mlabformat() is an option, not a function. I don't have access any longer to Stata 14, but see if


      Code:
      help marker label options
      mentions mlabformat() in your Stata. If it does not then presumably you need something like

      Code:
      gen mylabel = string(pc_scale, "%3.2f")
      and then feed that to mlabel();

      NOTE I do have access, as does almost anyone, to https://www.stata.com/manuals14/g.pdf which indicates that the option had not yet been introduced.
      Thank you so much, Nick! The problem is well addressed!

      Comment

      Working...
      X