Announcement

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

  • mlabel()

    Inquiring whether it is possible to have mlabel() option in a twoway scatter graph to only label a few points rather than all

  • #2
    Naturally, as some labels can always be empty strings, and in any case you can segregate code for the marker labels from the rest of the code.

    Code:
    sysuse auto, clear
    l make
    scatter mpg weight, ms(Oh) || scatter mpg weight if make == "Subaru", ms(none) mla(make) legend(off)
    
    gen make2 = make if make == "Subaru" 
    scatter mpg weight, ms(Oh) mla(make2)

    Comment


    • #3
      I know of no easy way to do this; however, this is the logic I have used: (1) make a clone (see "help clonevar") of the string variable you want to use for labels; (2) replace the values that you do NOT want to show up with missing/blank (i.e., " "); then use mlabel(varname) where varname is your new variable with blanks where you don't want a label; maybe someone else knows a better way?

      added: crossed with Nick's more comprehensive response

      Comment


      • #4
        Thanks
        I've tried out Nick Cox's and it worked perfectly.
        Many thanks

        Comment

        Working...
        X