Announcement

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

  • Simultaneously weighting points and labeling them?

    Hello!

    I am trying to make a scatter plot that simultaneously [a] uses analytic weighting to change the size of my markers according to the weight afforded to a specific variable (numberweight) and [b] labels each of my points with a numeric label (id).

    Here is what my command looks like with weighted markers, but no labels:

    twoway scatter var2 var1 [aweight=numberweight], msymbol(oh) || lfit var2 var1

    Here is what my command looks like with labels, but no weighted markers:

    twoway scatter var2 var1, mlabel(id) || lfit var2 var1

    Whenever I try to label the points and weight the markers at the same time (using both msymbol and mlabel), mlabel effectively cancels out the weighting effect of the msymbol, so my points end up labeled but are all the same size.

    Just wondering if there is a way to simultaneously do both; I can't figure it out. Thanks!

  • #2
    Hi,

    this has been asked previously on Statalist, see https://www.stata.com/statalist/archive/2006-06/msg00277.html. See also the remark on weighted markers in the help file of scatter. Moreover, minimal working examples are appreciated (e.g., using the auto.dta; sysuse auto). Only then errors or problems can be reproduced by others.

    Regarding your question, you can rely on overlaying several twoway plots:

    Code:
    sysuse auto
    twoway (scatter price mpg [aw=displace]) (scatter price mpg  , mlabcol(black) msym(i) mlabel(make)) , legend(off)
    Hope this helps

    Comment


    • #3
      Thanks so much! Appreciate the help.

      Comment

      Working...
      X