Hi all,
I am looking for an efficient way to make scatter plots overlaid by a "group". For example, suppose you have:
Essentially, what I want is the graph which results from
However, my actual data has 50 states, and it seems like there should be a more efficient way then to write the line of code 50 times to overlay 50 scatter plots on each other.
Would anyone know of an efficient way to overlay all scatterplots on one graph?
Thanks!
Vincent
I am looking for an efficient way to make scatter plots overlaid by a "group". For example, suppose you have:
Code:
set more off clear input y x str2 state 1 2 "NJ" 2 2.5 "NJ" 3 4 "NJ" 9 1 "NY" 8 0 "NY" 7 -1 "NY" 2 3 "NH" 3 4 "NH" 5 6 "NH" end
Code:
graph twoway (scatter y x if state == "NJ") /// (scatter y x if state == "NY") /// (scatter y x if state == "NH"), legend(order(1 "NJ" 2 "NY" 3 "NH"))
Would anyone know of an efficient way to overlay all scatterplots on one graph?
Thanks!
Vincent
Comment