Announcement

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

  • Side-by-side boxplots with markers for means

    Hello,

    I have country-level panel data for GDP per capita for the past 10 years that I wish to represent in a side-by-side boxplot (by years. So my x-axis would be years, y-axis would be GDP per capita).

    I also have categories of countries. Some countries are classified as "fragile" and others are "non-fragile".

    Is there a way to overlay the mean GDP value of "fragile" countries per year on the boxplot graphs? I am aware that others have attempted to do this using the "twoway rbar" method, but was wondering if there is a more efficient way, preferably sticking to the "graph box" syntax






  • #2
    The virtue of being "efficient" is often invoked, but rarely defined. Storage demands? Machine time? Programmer time? Something else?

    graph box does what it does, but it's not part of graph twoway and only with difficulty can be extended.


    stripplot from SSC is one of several community-contributed alternatives. Here we see each subset as (1) a quantile plot, (2) a conventional median and quartiles box, (3) whiskers going to 5 and 95% points where different from quartiles (which I think easier to explain than the Tukey 1.5 IQR rule) and (4) longer horizontal lines showing means.

    Code:
    sysuse auto, clear 
    set scheme s1color 
    stripplot mpg, over(rep78) box(barw(0.1)) pctile(5) cumul cumprob height(0.5) boffset(-0.1) refline vertical yla(, ang(h))
    Click image for larger version

Name:	stripplot.png
Views:	1
Size:	24.9 KB
ID:	1690726

    Comment


    • #3
      I see - I thought there must be a way within the confines of graph box, but seems like there are alternatives.

      Thank you very much Nick!

      Comment

      Working...
      X