Announcement

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

  • Show only some values in graph bar, percent stack

    Dear Statalisters,

    I'm trying to plot the breakdown of an aggregate measure by its components (countries). I have one variable per country. The code is the following:

    Code:
     graph bar (mean) country_variables, over(year, gap(*0.3) label(angle(45))) stack percent ytitle("%") legend(row(5) order(`legorder')) `bcolor' blabel(bar, format(%5.0f) position(center) size(vsmall))
    `legorder' and `bcolor' are locals I use to define the legend and the bar colors. The output is the following:

    Click image for larger version

Name:	Capture.PNG
Views:	1
Size:	54.4 KB
ID:	1655606


    What I would like to do is show only values for selected countries within bars, but I couldn't find any reference explaining how to do it.
    Thanks in advance!

    Federico



  • #2
    I am not clear exactly what you want to do within graph bar, but my guess is that it is not documented because it's not available. If the command allowed you to show the values of an arbitrary variable, as text then you could show a string variable with some values empty, but that doesn't seem to be allowed. (It is allowed with twoway bar.)

    I want to step back and consider your graphical challenge without committing myself to graph bar. This method of stacking bars appears to be popular because in principle a stacked bar chart encodes a great deal of information. The problem is that in practice it is often, dare I say usually, ineffective insofar as people typically struggle to decode that information easily. How many readers have looked at charts like this, felt satisfied that they understood the principle, but moved on quickly because it is hard to get much out of them?

    1. You have 16 years and perhaps 20 countries; it's part of the problem that I can't even be clear how many countries there are. That's a lot of data but also a lot of challenge to show it well.

    2. Scaling to percents may or may not be a good idea. We can't tell. Perhaps the problem really is about shares; perhaps absolute amounts are as or more important. Even assuming that shares are the big deal, we don't need the message that the shares add to 100%. There are other ways to show shares that are more effective.

    3. You are suppressing the legend that makes sense of this. That legend with perhaps 20 entries is going to take up a lot of real estate. If your graph is intended for a paper, you'd be lucky if they accepted a full colour submission, in which case the design is doomed.

    4. Small values -- including zeros if there are any -- are hard to read off. Perhaps they are noise, in which case why show them? In some examples the small values can be really interesting and/or important, in which case you need to allow focus on them: look, this case was at 0.1% at the start, but now it's 2%, or whatever. In plenty of applications -- economics, epidemiology, environmental science, eschatology -- the once small but exploding worrying case can be of prime concern.

    I would switch here to line plots of time series. In particular, what I have called a front-and-back plot allows a mixed strategy. Show all the data, but emphasise what you want to emphasise.

    https://journals.sagepub.com/doi/pdf...6867X211025838 is accessible. Note especially the scope for showing (for example) 4 subsets prominently out of 10 in total. (3 x 3 display showing 9 prominently of 20 or so might work not too badly.)

    Comment


    • #3
      Thank you for the suggestions, Nick!

      Fede

      Comment


      • #4
        A related thread here: https://www.statalist.org/forums/for...rent-variables

        Comment

        Working...
        X