[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
"Friedrich Huebler" <fhuebler@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: Scatterplot: Weighted markers change size |

Date |
Sun, 24 Aug 2008 15:43:46 -0400 |

To close this thread, here is a solution to my problem that was provided by Stata tech support. One has to duplicate the observations and recode the group variable in the duplicates so that the weights are distributed across all groups. . clear all . input x y weight group 1 1 1 1 2 1 2 1 1 2 4 2 2 2 8 2 end . scatter y x [w=weight], name(A) . twoway (scatter y x if group==1 [w=weight]) (scatter y x if group==2 [w=weight]), name(B) legend(off) . expand 2 . replace x = . if _n>(_N/2) . recode group (1=2) (2=1) if x==. . twoway (scatter y x if group==1 [w=weight]) (scatter y x if group==2 [w=weight]), name(C) legend(off) The legend is turned off so that it is easier to see that the markers in graphs A and C have the same size. A more complicated example is shown in a reply to a similar question by another list member. http://www.stata.com/statalist/archive/2008-08/msg00982.html Friedrich On Tue, Jul 29, 2008 at 7:36 PM, Friedrich Huebler <fhuebler@gmail.com> wrote: > -scatter- supports weights. When a scatterplot is drawn, all weighted > markers have a distinct size. This size changes when the data are > divided into two or more groups and then drawn as overlaid > scatterplots. I am looking for a way to retain the size of the > original markers. The problem is best understood with an example. > > clear all > input x y weight group > 1 1 1 1 > 2 1 10 1 > 1 2 100 2 > 2 2 1000 2 > end > scatter y x [w=weight], name(A) > twoway (scatter y x if group==1 [w=weight]) /// > (scatter y x if group==2 [w=weight]), name(B) > > Compare graphs A and B. In graph A all four markers have a different > size. In graph B there are two pairs of markers with the same size. I > would like to have the same marker sizes in graph B as in graph A > while keeping the colors that identify the two different groups. How > can I do this? > > Thanks, > > Friedrich * * 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/

- Prev by Date:
**Re: st: crude binary analysis** - Next by Date:
**st: probit vs. reg postestimation** - Previous by thread:
**st: bihistogram** - Next by thread:
**st: probit vs. reg postestimation** - Index(es):

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