Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

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

Re: st: Re: Make xline on top of graph?

From   Nick Cox <>
Subject   Re: st: Re: Make xline on top of graph?
Date   Fri, 22 Jul 2011 08:33:02 -0500

-triplot- (SSC) supports a -by()- option. It is not exactly equivalent
to -by()- as a standard -twoway- option but it certainly permits small
multiples. -triplot- also allows different point (marker) symbols.

Fond though I am of triangular plots, they don't always work well, and
alternative scatter plots often work as well as better. I hope to
return this topic in a future Speaking Stata column in the Stata


On Fri, Jul 22, 2011 at 8:00 AM, Paul Burkander <> wrote:
> Thanks, the scatteri plot worked very well.
> I'll have to consider the triangular plots.  I am having a problem in
> that where there isn't clumping of bars it's hard to distinguish them.
> Perhaps the triangular plot would be more clear, but then it seems
> it'll be harder to group by type of observations, unless I do it by
> color.
> Thanks for the help.
> On Thu, Jul 21, 2011 at 2:43 PM, Nick Cox <> wrote:
>> Let's suppose you want lines at x = 1000, 2000, 4000. Superimpose on
>> top of your -twoway- graph call
>> || scatteri 0 1000 1 1000 , recast(line) || scatteri 0 2000 1 2000 ,
>> recast(line) || scatteri 0 4000 1 4000 , recast(line)
>> You will want to tweak widths, colours, etc. as well.
>> In many fields triangular plots (many alternative names exist) are
>> used for such data. -triplot- from SSC is a Stata implementation.
>> An easy alternative is to plot (var2 - var1) versus var3 which
>> preserves the information in the three variables. For example, U.S.
>> elections can be plotted in terms of
>> (Republican vote - Democrat vote) vs sum of independent votes
>> which is not too difficult to think about. Even if the x variable is a
>> nonsense dimension, it spreads out the data.
>> I reviewed some possibilities in this field at the 2008 London users'
>> meeting.
>> Nick
>> On Thu, Jul 21, 2011 at 11:39 AM, Paul Burkander <> wrote:
>>> Here's my situation: I have about 5,000 observations and three key
>>> variables, I'll call them var1 var2 and var3.  Each is between 0 and
>>> one and the sum of the three variables is one.
>>> I'd like to have a graph that's sort of like a stacked bar chart to
>>> show the relative proportions of each variable across the 5000
>>> observations.  I've succeeded in doing this by using the twoway bar
>>> option.  I sort on var1, then graph var1+var2+var3, then var1+var2,
>>> then var1.  That part seems to have worked out fine.
>>> However, the 5000 observations fall into three distinct categories,
>>> and I'd like to first sort by these categories then by var1.  I'd like
>>> it to be clear where the demarcation between categories is.  I tried
>>> xline, but it seems to be drawn first, so that my bars are drawn over
>>> top if it and it can only be seen below 0 and above 1.  I don't see
>>> any option to make it be drawn on top.
>>> I also tried "graph combine," but there's a large difference in the
>>> number of observations in each category, and each of my separate
>>> graphs was being drawn with the same width, so the graph was
>>> misleading.

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index