Saturday, March 04, 2006

st: Thanks => graph twoway bar horizontal vs. graph hbar

Thank you for your help, Drs. Nichols & Cox; you have solved my problems. Austin, I actually tried the -relabel- suboption inside -over- but it did not work, as you pointed out. I wonder why. I feel the -relabel- suboption should have solved my problem #2. Am I missing something or is this a problem in Stata? ---Hiroshi

Date: Fri, 3 Mar 2006 13:53:31 -0500 From: "Austin Nichols" <> Subject: Re: st: graph twoway bar horizontal vs. graph hbar

(1) help region_options##remarks1 shows that the addition of the option plotregion(margin(zero)) puts the bars against the axes.

(2) help graph bar##over_subopts suggests the -relabel- option should make the labels disappear with the addition of relabel(3 " " 6 " " 9 " ") as a suboption of over(), but it doesn't work. But this does: relabel(3 "`: di char(160)'" 6 "`: di char(160)'" 9 "`: di char(160)'") I believe.

On 3/3/06, Hiroshi Maeda <> wrote: 1) How to eliminate a gap(space) between the y axis and the location where bars begin in GRAPH_01, using the "graph twoway bar, horizontal" command? 2) How to make the labels 3, 6, & 9 on the y axis (the categories intended to be invisible for an aesthetic reason) disappear, using the "graph hbar" command?

* * For searches and help try: * * *


Date: Fri, 3 Mar 2006 18:59:38 -0000 From: "Nick Cox" <> Subject: st: RE: graph twoway bar horizontal vs. graph hbar

As it happens, I started work last night on a rough-and-ready program in this territory called -textbarplot-.

Re-creating your data (note the short-cuts)

#delimit ; clear; set obs 11; gen TYPE_YEAR = _n;

lab define TYPE_YEAR 1 "General, 1900" 2 "General, 1930" 4 "Mental, 1900" 5 "Mental, 1930" 7 "TB, 1900" 8 "TB, 1930" 10 "OS, 1900" 11 "OS, 1930"; lab val TYPE_YEAR TYPE_YEAR;

gen AVE_NUM_BED=82 if TYPE_YEAR==1; replace AVE_NUM_BED=81 if TYPE_YEAR==2; replace AVE_NUM_BED=508 if TYPE_YEAR==4; replace AVE_NUM_BED=780 if TYPE_YEAR==5; replace AVE_NUM_BED=103 if TYPE_YEAR==7; replace AVE_NUM_BED=130 if TYPE_YEAR==8; replace AVE_NUM_BED=68 if TYPE_YEAR==10; replace AVE_NUM_BED=60 if TYPE_YEAR==11;

I then went

. textbarplot TYPE_YEAR AVE_NUM_BED, plotregion(margin(zero))

which gets you much of the way there. (You can add further options.)

As I have suggested various times in this list, for the flexibility you want, -twoway bar, hor- is the way to go, as I don't think -graph hbar- can solve your problem 2) without creating further problems.

Your problem 1) is I think solved by the option above.

Note that -textbarplot- can be recast to a different form by -recast(dot)-, -recast(dropline)-, -recast(spike)- by courtesy of some cute Wigginsypokery.


-- Hiroshi Maeda University of Illinois at Chicago

* * For searches and help try: * * *


Links to this post:

Create a Link

<< Home

This page is powered by Blogger. Isn't yours?