Thanks as always to Kit Baum, a new program sepscatter is available from SSC, to be installed using ssc inst sepscatter.
As usual, the help file gives the documentation, so the better thing for me to do is to give some examples so you can see whether you care.
The canonical example here uses the auto data. Imagine you want to separate foreign and domestic cars on a scatter plot of mpg versus weight.
A little study of the manual makes it clear that you can superimpose a plot of foreign cars and one of domestic cars.
The legend that springs up is dopey as far as you are concerned, but that can be fixed, and while you are doing that you can spell out precisely what you wish in the way of marker symbols and colours and so forth. So far, not so bad, but when you start to wonder about distinguishing the five levels of repair record, most of us protest inwardly at the thought of spelling out the commands for five separate graphs, all superimposed.
You may know another way to approach this. This kind of problem was one of the main reasons for adding the separate command to Stata back in Stata 6. The keen Stata user will naturally have memorised http://www.stata-journal.com/sjpdf.h...iclenum=gr0023 and be able to add the extra flourish of the veryshortlabel option (that is, very short label).
This does most of the work but scatter is in despair about what ytitle() you might want and the default choice of markers may not be especially suitable for the purpose (depending naturally on what graph scheme you have in place).
So, after some years of these half-fudged solutions I got round to a convenience command with my idea of a fair first approximation, in which the separation is done on the fly and there is some inbuilt intelligence on markers, legend and axis title. Here are two examples:
In the second case, you can play with different marker symbols for the five levels of repair record, but it's hard to improve on just showing the values 1 to 5. Usually scatter would insist that to show five distinct variables using marker label variables you need to spell out (here) mla(rep78 rep78 rep78 rep78 rep78) and more details too, but sepscatter automates that for you, given the mylabel() option.
Running sepscatter with combineplot (also SSC) is a way of getting several such graphs all at once.
SEE LESS|GO TO POST
As usual, the help file gives the documentation, so the better thing for me to do is to give some examples so you can see whether you care.
The canonical example here uses the auto data. Imagine you want to separate foreign and domestic cars on a scatter plot of mpg versus weight.
A little study of the manual makes it clear that you can superimpose a plot of foreign cars and one of domestic cars.
Code:
sysuse auto, clear set scheme s1color scatter mpg weight if foreign || scatter mpg weight if !foreign
The legend that springs up is dopey as far as you are concerned, but that can be fixed, and while you are doing that you can spell out precisely what you wish in the way of marker symbols and colours and so forth. So far, not so bad, but when you start to wonder about distinguishing the five levels of repair record, most of us protest inwardly at the thought of spelling out the commands for five separate graphs, all superimposed.
You may know another way to approach this. This kind of problem was one of the main reasons for adding the separate command to Stata back in Stata 6. The keen Stata user will naturally have memorised http://www.stata-journal.com/sjpdf.h...iclenum=gr0023 and be able to add the extra flourish of the veryshortlabel option (that is, very short label).
Code:
separate mpg, by(rep78) veryshortlabel scatter mpg? weight
So, after some years of these half-fudged solutions I got round to a convenience command with my idea of a fair first approximation, in which the separation is done on the fly and there is some inbuilt intelligence on markers, legend and axis title. Here are two examples:
Code:
sepscatter mpg weight, separate(foreign) legend(pos(1) col(1) ring(0)) sepscatter mpg weight, separate(rep78) myla(rep78)
In the second case, you can play with different marker symbols for the five levels of repair record, but it's hard to improve on just showing the values 1 to 5. Usually scatter would insist that to show five distinct variables using marker label variables you need to spell out (here) mla(rep78 rep78 rep78 rep78 rep78) and more details too, but sepscatter automates that for you, given the mylabel() option.
Running sepscatter with combineplot (also SSC) is a way of getting several such graphs all at once.
SEE LESS|GO TO POST
Comment