Re: st: weight marker symbol fill size and color?

 From David Airey <[email protected]> To [email protected] Subject Re: st: weight marker symbol fill size and color? Date Sun, 24 Aug 2008 11:52:37 -0500

.

The answer is no, Stata does not weight the same way, so color and weights cannot be combined as in the R example.

-Dave

On Aug 24, 2008, at 11:37 AM, David Airey wrote:

.

But if I combine this approach with weighting, would the symbol size be changed in the same way compared to when I weight in one scatter? e.g..

twoway (scatter ... if z>=9 [aw=z], ... mcolor(gs12)) (scatter ... if z>7.5 &
z<9 [aw=z], ... mcolor(gs8)) (scatter ... if z<7.5 [aw=z], ... mcolor(gs4))

vs

twoway (scatter y x [aw=z])

I'll see...Thanks.

-Dave

On Aug 24, 2008, at 11:23 AM, Stas Kolenikov wrote:

The only way (at least that I know of) to change color is to split
your data and do several scatterplots:

twoway (scatter ... if z>=9, ... mcolor(gs12)) (scatter ... if z>7.5 &
z<9, ... mcolor(gs8)) (scatter ... if z<7.5, ... mcolor(gs4))

This can probably be automated with a ~15 line wrapper program that
takes in z, y, z and the thresholds.

Graphics in R is notably stronger than in Stata.

On Sun, Aug 24, 2008 at 10:42 AM, David Airey
<[email protected]> wrote:

.

At this page, we see how to change symbol size by using (analytic) weights:

http://www.stata.com/support/faqs/graphics/gph/graphdocs/scatter5.html

e.g.,

webuse census
scatter death medage [w=pop65p], msymbol(circle_hollow)

Can we change both symbol size and color shading as in the R example below?

-Dave

###------------------create the test data.frame
y = c(.4, 1, 2.15, 1.8, 2.7, 2.2, 1.3, .25, 1.1, .1)
x = c(.35, .4, .41, 1.4, 2.1, 2.25, 2.15, 2.2, 1.45, 1.3)
z = c(9, 7, 7.5, 7.3, 7, 7.1, 7.75, 9.5, 8, 10)
d = data.frame(x = x, y = y, z = z)

d\$col = gray(.5)
d\$col[d\$z>=9] = gray(.2)
d\$col[d\$z<7.5] = gray(.7)
#thikness = sqrt(d\$y^2 + d\$x^2)
thikness = abs(d\$y) + abs(d\$x)

###----------------simple, 2-D plot
plot(d\$x, d\$y, pch=19, cex=(d\$z-min(d\$z)/1.5), xlim = c(-1.5,4), ylim =
c(-2.5,5), col=d\$col)
```

--
Stas Kolenikov, also found at http://stas.kolenikov.name
Small print: I use this email account for mailing lists only.
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```
```*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```
```*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```