Bookmark and Share

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


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

Re: st: -graph hbar- bars with colour used to identify groups of obs


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: -graph hbar- bars with colour used to identify groups of obs
Date   Wed, 6 Apr 2011 16:20:23 +0100

A couple of footnotes:

1. -labmask- is user-written. For other examples of how to use it, see

SJ-8-2  gr0034  . . . . . . . . . .  Speaking Stata: Between tables and graphs
        (help labmask, seqvar if installed) . . . . . . . . . . . .  N. J. Cox
        Q2/08   SJ 8(2):269--289
        outlines techniques for producing table-like graphs

2. When using -twoway- for this kind of graph, the y axis ticks can
also be dropped:

yla(, notick)

Nick

On Wed, Apr 6, 2011 at 3:58 PM, Austin Nichols <[email protected]> wrote:
> Stephen--
>
> It's often easier to work in -twoway bar- for better control of graphs e.g.
>
> clear all
> input noctry pp_all accession
>  1  9.019705 0
>  3  3.933862 1
>  6  13.28287 1
>  7  12.16459 0
>  9  10.973   0
>  11  11.85057 0
>  12  10.47666 1
>  13  12.20738 1
>  14  10.44716 1
>  15  8.407103 0
>  16  7.525132 1
>  18  5.768504 0
>  19  5.594264 0
>  20  10.31553 1
>  21  13.07521 0
>  23  7.804794 1
>  24  4.923772 1
>  25  6.715902 0
>  26  2.96161  0
>  27  8.402966 0
>  31  5.381824 0
> end lab var noctry "Country"
> lab var accession "1: Accession country"
> label var pp_all "Rate (%)"
> lab def noctry 1 "BE" 2 "BG" 3 "CZ" 4 "DK" 5 "DE"
> lab def noctry 6 "EE" 7 "IE" 8 "EL" 9 "ES" 10 "FR", modify
> lab def noctry 11 "IT" 12 "CY" 13 "LV" 14 "LT" 15 "LU", modify
> lab def noctry 16 "HU" 17 "MT" 18 "NL" 19 "AT" 20 "PL", modify
> lab def noctry 21 "PT" 22 "RO" 23 "SI" 24 "SK" 25 "FI", modify
> lab def noctry 26 "SE" 27 "UK" 30 "IS" 31 "NO", modify
> lab val noctry noctry
> sort pp_all
> g x=-_n
> decode noctry, gen(lab)
> labmask x, val(lab)
> ren pp_all y
> loc o , barw(.3) horiz leg(off) yla(-1/-21,val angle(0)) yti(" ")
> tw bar y x if acc `o'||bar y x if !acc `o'
>
>
> On Wed, Apr 6, 2011 at 10:38 AM, Eric Booth <[email protected]> wrote:
>> <>
>>
>> Your bars look off-center because there are spaces for empty groups/bars.  Add the nofill option.
>> Here's some changes to your graph:
> <snip>
>> On Apr 6, 2011, at 9:25 AM, <[email protected]>
>>  wrote:
>>
>>> I want to use -graph hbar- to show poverty rates across countries, where
>>> the countries are ordered by poverty rate, and with the bars being one
>>> colour for one country group, and another colour for the other country
>>> group.  I also want a black&white/shades-of-grey picture.
>>>
>>> Problem: I can draw the graph, but the bars are not centred over the
>>> "slot" at each bar's base. For one group, they are left-justified within
>>> the "slot"; for the other group they are right-justified. So, the graph
>>> looks odd. See http://screencast.com/t/GIGwu99oy
>>>
>>> I've looked at the various options (including -asyvars-), and can't find
>>> a fix. Below are the data and the code I've tried.
>>>
>>> Advice please.

*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index