Statalist


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

RE: st: RE: gr bar for string variable


From   "b. water" <[email protected]>
To   <[email protected]>
Subject   RE: st: RE: gr bar for string variable
Date   Thu, 3 Apr 2008 23:14:30 +0000

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: [email protected]
> To: [email protected]
>
> 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
> [email protected]
>
> 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/



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