Announcement

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

  • Overlay different plots

    Dear all,

    Is there a way to achieve what the following code produces:
    Code:
    use https://stats.idre.ucla.edu/stat/stata/notes/hsb2, clear
    
    twoway (scatter read write if race == 1) ///
           (scatter read write if race == 2) ///
           (scatter read write if race == 3) ///
           (scatter read write if race == 4)
    Without having to write all the possible values of race? Something like:
    Code:
    twoway (scatter read write), by(race)
    But producing one graph instead of four?

    Thank you!

  • #2
    Consider sepscatter from SSC.

    https://www.statalist.org/forums/for...lable-from-ssc

    In this case, I don't find the result compelling. The result is what has been called the paella problem, the lesser known cousin of the spaghetti problem.

    One alternative is fabplot from the Stata Journal -- see https://www.statalist.org/forums/for...ailable-on-ssc for the gist.

    Another is use convex hulls too. Compare https://www.statalist.org/forums/for...-scatter-plots

    Code:
    use https://stats.idre.ucla.edu/stat/stata/notes/hsb2, clear
    set scheme s1color 
    sepscatter read write, sep(race) name(G1, replace)
    fabplot scatter read write, by(race) name(G2, replace) frontopts(ms(O) mcol(blue%50) msize(large))
    Click image for larger version

Name:	separate_G1.png
Views:	1
Size:	60.4 KB
ID:	1707739
    Click image for larger version

Name:	separate_G2.png
Views:	1
Size:	106.2 KB
ID:	1707740

    Comment

    Working...
    X