Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Grouping markers


From   Maarten buis <[email protected]>
To   [email protected]
Subject   Re: st: Grouping markers
Date   Mon, 14 Sep 2009 21:36:39 +0000 (GMT)

--- On Mon, 14/9/09, Eran Bendavid wrote:
> I am trying to create a scatter plot,
> and I would like to present the markers as belonging to
> separate clusters.  Aside from providing labels, which
> clutter the image too much, is there another useful way to
> do this?  My thought was to cluster by marker color and
> shape, but I'm  open to suggestions.  (For
> example, say I'm graphing price against quantity, and each
> data point comes from a particular city and year, and I
> would like to highlight which data points come from the same
> city.)

My guess is that you will get the clearest representation of your data
with the -by()- option, but the example below also shows how to create
a graph with different markers for different groups. 

Hope this helps,
Maarten

*------------------- begin example ----------------------------
sysuse auto, clear
twoway scatter price mpg, by(rep78)

levelsof rep78
local levs `r(levels)'

foreach lev of local levs {
	local gr "`gr' || scatter price mpg if rep78 == `lev'"
	local leg `"`leg' `lev' "rep78==`lev'" "'
}

twoway `gr', legend(order(`leg'))
*------------------- end example -------------------------------
( For more on how to use examples I sent to statalist see:
http://www.maartenbuis.nl/stata/exampleFAQ.html )

--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany

http://www.maartenbuis.nl
--------------------------





      

*
*   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/



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