[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
David Airey <david.airey@vanderbilt.edu> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: RE: gr bar for string variable |

Date |
Thu, 3 Apr 2008 21:30:51 -0500 |

.

When the new graphics were introduced, I read the graphics manual front to back. Then Mitchell's text came out, and that helped a lot (what has happened to the second edition?). Yet, all the same, whenever I find myself in the online help, I am reminded at the complexity of Stata graphics. Most of the time, my guesses at the option needed is correct, which says that the job done by the graphics programmers was well done. Brilliant, really. With the graphics editor, these days I generate a near miss plot, and modify it to completion in the editor. Sometimes, I resist this so I keep my understanding of the Stata graphic commands fresh. A little weird, I admit.

-Dave

On Apr 3, 2008, at 6:14 PM, b. water wrote:

stata 8.2, windows xp,

nick, thanks again for the -catplot-, which turned out to be indeed quite versatile.

on a separate note, i wonder whether frequent (or perhaps fluent or tutors of) stata graphic's users has any tips to share on how to they learnt/mastered stata graphical functions. i use [G] & michael mitchell's A Visual Guide to Stata Graphics to help me built the desired graphs. yet in spite of these, still found myself seeking advice/help.

i notice in this group is how relatively little graphs queries was asked. one possible obvious explanation would be that the graph functions are used a lot less than the statistical functions. another possible explanation is that the graph functions are that 'easy' queries to the list are few (this could also explain why there is no stata corps' netcourse for stata graphics), which made me wonder whether i am not approaching it right in getting au-fait with stata graphs functions. hence would appreciate tips on how one learns & perhaps masters stata graph functions.

regards,

bw

Subject: st: RE: gr bar for string variable_________________________________________________________________

Date: Fri, 7 Mar 2008 19:16:05 +0000

From: n.j.cox@durham.ac.uk

To: statalist@hsphsun2.harvard.edu

b. water:

You asked about bar graphs in January. In that thread -catplot- from SSC

was flagged as an

alternative to do-it-yourself counting and graphing. That remains true

for your questions

here.

Here is an example.

sysuse auto, clear

catplot hbar foreign rep78, percent(rep78) asyvars bar(1, bcolor(pink))

bar(2, bcolor(blue))

-catplot- can calculate percents. With your route, you would have to do

more work before you

called the graph command.

-catplot- can give you different colours. You use the option - asyvars-.

That's just the

same option as -graph bar-, -graph hbar-, etc. It's tacit that - asyvars-

gives different

colours, but think of it this way: if -graph- knows that it is showing

separate variables, it

knows that it must show them distinctively. You can control the colours

by calling up -bar(,)-

as desired.

The example doesn't use string variables, but -catplot- will handle them

without demur.

Nick

n.j.cox@durham.ac.uk

b. water

stata 8.2,

i have data set-up like this:

injurytype year

typeII 2007

minimal 2003

typeII 2003

minimal 2003

typeIII 2005

typeIV 2006

and so on (the range of the injury type is minimal, typeI to typeIV

while the year is 2003 - 2007).

i am building a graph bar like the one in stata v. 8 [G] page 135 where

in place of region 1 in the example, i would have the year and instead

of 1 to 9 regional division, i would have the 5 types of injury (i.e.

minimal, typeI to typeIV). following my earlier query (around new year's

time), i did:

gen x=1

gr bar (count) x, over(injurytype) over(year)

which produces the one of the graph that i want except for one thing:

the injury types, displayed on x-axis suffered from 'overprinting'. i

know i can try:

gr hbar (count) x, over(injurytype) over(year) ysize(10)

which did solve the overprinting but i would be grateful if anyone can

tell me:

1. how can i make, instead, each bar to be of a different color and

displaying the color legend (e.g. red for minimal etc), so that i can

suppress injurytype being shown on the x-axis (but still displaying the

year) (someone need to tell me how to achieve this), and

2. how can i, instead of a -count-, produce a proportion or percentage

of each type of injury over (year) i.e. on a graph bar, the y-axis would

shows either proportion or percentage rather than count.

*

* For searches and help try:

* http://www.stata.com/support/faqs/res/findit.html

* http://www.stata.com/support/statalist/faq

* http://www.ats.ucla.edu/stat/stata/

Pack up or back up–use SkyDrive to transfer files or keep extra copies. Learn how.

hthttp://www.windowslive.com/skydrive/overview.html?ocid=TXT_TAGLM_WL_Refresh_skydrive_packup_042008

*

* For searches and help try:

* http://www.stata.com/support/faqs/res/findit.html

* http://www.stata.com/support/statalist/faq

* http://www.ats.ucla.edu/stat/stata/

-- David C. Airey, Ph.D. Pharmacology Research Assistant Professor Center for Human Genetics Research Member Department of Pharmacology School of Medicine Vanderbilt University Rm 8158A Bldg MR3 465 21st Avenue South Nashville, TN 37232-8548 TEL (615) 936-1510 FAX (615) 936-3747 EMAIL david.airey@vanderbilt.edu URL http://people.vanderbilt.edu/~david.c.airey/dca_cv.pdf URL http://www.vanderbilt.edu/pharmacology * * For searches and help try: * http://www.stata.com/support/faqs/res/findit.html * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**Follow-Ups**:**RE: st: RE: gr bar for string variable***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

**References**:**RE: st: RE: gr bar for string variable***From:*"b. water" <barleywater@hotmail.com>

- Prev by Date:
**RE: st: using the first n observations in a dataset w/o evaluating the whole thing?** - Next by Date:
**R: R: st: multile comparison among incidence rates** - Previous by thread:
**RE: st: RE: gr bar for string variable** - Next by thread:
**RE: st: RE: gr bar for string variable** - Index(es):

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