Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: variable color in Stata 8 plot

From   "FEIVESON, ALAN H. (AL) (JSC-SK) (NASA)" <[email protected]>
To   "statalist (statalist)" <[email protected]>
Subject   st: variable color in Stata 8 plot
Date   Fri, 24 Jun 2005 15:31:09 -0500

Title: variable color in Stata 8 plot

Hello - I would like to plot y vs x with the plot symbol changing color depending on a third variable, say z. Is this possible to do in Stata 8 without defining separate y's for each value of z? For example, if I wanted to plot with a different symbol, I could do something like

gen str1 sym="A" if z==0
replace sym="B" if z=1
scatter y x,mlab(sym)

What I would like to do is

gen str4 sym = "red' if z==0
replace  sym="blue" if z==1
scatter y x,mcolor(sym)

except it doesn't work.

I know I could accomplish this by
gen y0 = y if z==0
gen y1=y if z==1
scatter y0 y1x,mcolor(red blue)

but I am going to do this for a lot of different y's and I don't want to create 2 new variables for each one of them.

Al Feiveson

© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index