Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Labeling x-axis of grouped bar graph

    Hi,

    I'm having trouble labelling a bar graph in Stata. The current output looks like this:
    Click image for larger version

Name:	Graph.png
Views:	1
Size:	20.7 KB
ID:	1456854


    Produced by the following code:
    Code:
    //Label variables
    lab var CAAR_1 "1"
    lab var CAAR_2 "2"
    lab var CAAR_3 "3"
    lab var CAAR_4 "4"
    lab var CAAR_5 "5"
    
    graph bar CAAR_1 CAAR_2 CAAR_3 CAAR_4 CAAR_5, over(group) ascategory ///
    title("Abnormal returns per group") ytitle("Size-adjusted return (%)")
    So, the data is grouped by three categories which I have labelled and these are displayed correctly in the bottom. The bars represent different years, which is why I have labelled those 1 to 5.
    However, Stata still displays 'mean of CAAR_1", etc. rather than the label "1" I have given that variable.

    I have checked the manual and these forums and tried almost all the options. One suggested solution I have found is to use tabplot (ssc install) as it will always number bars. But it seems to me a simpler solution should exist. But all the options I try either effect the Y-label or the label of over().

  • #2
    That code doesn't reproduce the graph, if only because there are no data in your post.

    There are just two kinds of problem with the graph that I can see:

    1. The gratuitous text "mean of" appears because graph bar defaults to graph bar (mean) whereas it seems that you want graph bar (asis). This is documented in the help:

    mean is the default when varname or varlist is specified and stat is not specified.
    Alternatively, if you are showing means, then you may need to reach in to re-define the labels.

    2. The text labels on the x axis overlap painfully. Other than considering shorter labels, the most obvious choice to me is not to use tabplot (which should be regarded as a Stata Journal program) but to use graph hbar. Conversely, I wouldn't want to see bare variable names like CAAR_1 on a graph, but you don't have much room for anything more than 1 2 3 4 5.

    Comment

    Working...
    X