Announcement

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

  • Scatter with different markers for categories in colorvar

    Hi,

    I want to do a scatter plot by regions, with a different marker symbol for each category. My code is:

    sysuse census,clear
    scatter medage pop, msymbol(Oh Dh Th ) colorvar(region) colordiscrete zlabel(, valuelabel) coloruseplegend

    However, I cannot get different markers by region. Can anyone provide suggestions? I appreciate it.

    Thanks,

    Norman M


  • #2
    https://www.statalist.org/forums/for...lable-from-ssc offers one approach.

    Comment


    • #3
      Graph colors by variable is introduced in from Stata 18. If you use Stata 18 now, I don't find any wrong in your code. However, if your Stata version is lower than 18, Stata don't support that. https://www.stata.com/new-in-stata/g...s-by-variable/

      Edit: Sorry for missing the target. You want to have different symbols not colors. As far as I know, Stata don't support different symbols if you have only one y-variable in implemental twoway scatter command:
      msymbol(symbolstylelist)......The "list" specifiers shown above are available only when multiple y-variables are specified, with one specifier allowed per y-variable; otherwise, the standard specifiers listed in the option should be used.
      Nick just provide you a feasible workaround.
      Last edited by Chen Samulsion; 10 Feb 2025, 07:25. Reason: miss the target

      Comment

      Working...
      X