Announcement

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

  • Spacing of Bars in graph bar

    I'm using "graph bar" to generate a (vertical) bar graph of percentages that are stored in several variables using the "as is" option. I want to display the number of cases that were used in computing the percentages at the top of the bars. These numbers are also stored in variables in the data set.

    It appears that blabel doesn't offer this capability, so I'm pulling the count of cases into a series of macros and using the "text" option to display the values of these macros on the graph above the bar.

    I was able to locate the vertical position of these labels directly by using the value being graphed for the bar. But I had to resort to a trial and error method to locate the labels on the horizontal axis.

    I'm likely to have to do this again, and would like to know the formula that STATA uses to calculate the location of the bars so I can calculate these positions instead of using trial and error.

    If there is someway to use blabel I'm open to that as well.

    Thanks

    Doug Sharp

  • #2
    Not your question, but this example from tabplot (SSC) might interest people interested in this thread.

    Code:
    set scheme s1color 
    sysuse auto, clear 
    capture ssc inst tabplot 
    su rep78 
    bysort rep78 : gen toshow = string(_N) + "  (" + string(100 * _N/r(N), "%2.1f") + "%)"
    tabplot rep78, showval(toshow) sub(frequency and %)
    Click image for larger version

Name:	tabplot.png
Views:	1
Size:	12.0 KB
ID:	367252

    Comment


    • #3
      Those colours are just the defaults with my chosen graph scheme, given other choices. I am not especially fond of the orange choice there. Naturally, it can be tuned:

      Code:
      tabplot rep78, showval(toshow, mlabcolor(black)) sub(frequency and %)

      Comment

      Working...
      X