Announcement

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

  • Figure horizontal time line with bars

    Dear Stata community

    This is my first post here, so maybe I'll say something first: I've gotten numerous very useful hints here and like to thank all for their help!

    For one question, though, I could not find a solution. I like to create a horizontal stacked bar chart (maybe using the function graph hbar ... , stack) for a timeline to obtain a figure like this (the upper part only):

    https://ourworldindata.org/uploads/2...ernational.png

    Notice that for each country, years are either colored or not colored. In the example figure mentioned above it is done for wars but I want to do it with recessions and for a select group of countries.

    Here is a sample code to create a basic data set:

    clear
    input float(year country_id recession)
    2009 101 1
    2010 101 0
    2011 101 0
    2012 101 1
    2013 101 0
    2014 101 0
    2015 101 0
    2009 102 1
    2010 102 0
    2011 102 0
    2012 102 1
    2013 102 0
    2014 102 0
    2015 102 1
    end
    Perhaps someone has created the kind of chart I'm looking for and can help me out?

    Thanks a lot!
Working...
X