Statalist


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

RE: st: Problems with -triplot-


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: Problems with -triplot-
Date   Fri, 6 Feb 2009 14:39:27 -0000

triplot p q r, c(l l) mcolor(pink blue)

Nick 
[email protected] 

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Nick Cox
Sent: 06 February 2009 13:12
To: [email protected]
Subject: RE: st: Problems with -triplot-

Thanks to Friedrich for his comments. 

Fortunately, I see no real problems here. 

The key to understanding -separate()- is laid out tersely in the help: 

"separate() indicates that observations are to be subdivided into
classes according to a
        specified variable. A legend will be shown if and only if more
than one class is so
        defined. Each class is plotted as if it defined a single
variable."

Note that last sentence. 

To back up slightly, the one simple idea about -triplot- is that you
feed it 

triplot p q r 

and it does some school student algebra (or trigonometry) to convert to
that to a

scatter y x 

together with extra bits and pieces that are of considerable cosmetic
importance, but are nevertheless secondary to the logic. 

If you say -separate()-, -triplot- converts that (in your example) to a

scatter y1 y2 x 

using no more than (surprise) the -separate- command. So you need to
spell out 

scatter y1 y2 x, c(l l) mcolor(pink blue) 

or more precisely, 

triplot p q r x, c(l l) mcolor(pink blue)

or whatever. Each class becomes a separate variable, and you apply
standard -twoway- syntax to get the desired result. 

As for the -legend()-, -triplot- doesn't try to be smart about the
legend but it does not have to be because you maintain full control of
it. The default is indeed likely to be lousy. A better default would be 

legend(ring(0) pos(1) col(1)) 

and perhaps I should wire that in. (Note the -legend()- pops up
spontaneously only if -separate()- is issued, as indicated in the help.)


If you are following along, you'll see that the way to get -triplot- to
superimpose multiple sets of triangular coordinates is to -stack- or
-reshape- to a long data structure with a grouping variable. 

Friedrich's questions have given me ideas for small improvements to your
code and help. 

Nick 
[email protected] 

Friedrich Huebler

To clarify my question, I would like to have separate lines, one line
for each country.

Friedrich

On Thu, Feb 5, 2009 at 4:54 PM, Friedrich Huebler <[email protected]>
wrote:
> Nick Cox recently announced an updated version of his -triplot-
> package, available from SSC. I encountered some problems with the
> program.
>
> I am trying to generate a graph similar to Figure 15 in Cox (2004),
> but with data from two countries. I would like to connect the data
> points for each country but when I draw the graph with the options
> c(l) and separate(country), only the points from the first country are
> connected. Is it possible to connect the points from the second
> country, too? Can the appearance of the markers for the second country
> be changed? Options like mcolor() only affect the markers for the
> first country.
>
> There is also a problem with the legend. At the default position below
> the graph, the legend partly covers the label for the lower side of
> the triangle.
>
> Friedrich
>
> Reference: Cox, Nicholas J. 2004. Speaking Stata: Graphing categorical
> and compositional data. Stata Journal 4, no. 2: 190-215.
> http://www.stata-journal.com/article.html?article=gr0004


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