/**************************************************************** * Publication timeline plot * * Nicolas Duquette * * nduquett@usc.edu * * @NicDuquette * * * * http://www.nicolasduquette.com/ * * * * Free to use for whatever. If you make something cool * * or make big improvements, please share. * * * * This version 2020-apr-08 * * * ****************************************************************/ // ===================== // DEFINE MACROS global figout "`c(pwd)'" // Target directory for figures. // If you don't change it, the `c(pwd)' // local will define this as the current // working directory // ===================== // GENERATE DATA // These integers correspond to recent years in Stata's // date formats. clear input start fpres fsub frr accept publish 43087.00 43167.00 43492.00 43595.00 43774.00 43924.00 42493.00 42716.00 43079.00 43122.00 43426.00 43494.00 43217.00 43499.00 43676.00 43994.00 44091.00 44168.00 41437.00 41503.00 41954.00 42048.00 42346.00 42432.00 42126.00 42348.00 42493.00 42617.00 42733.00 42776.00 42516.00 42852.00 43098.00 43210.00 43305.00 43353.00 41592.00 41721.00 42079.00 42422.00 42757.00 42813.00 43449.00 43600.00 43754.00 44109.00 44346.00 44510.00 43392.00 43921.00 . . . . 44192.00 . 44479.00 44222.00 . . . end foreach var in start fpres fsub frr accept publish { replace `var'=`var'-(365.35*63) format `var' %td } // Sort by date started gsort start // Define today's date global today "d(`c(current_date)')" // Create end-of-period variable at either acceptance or today gen end=accept replace end=$today if accept==. // Create a counting ID, which will also serve as the vertical // axis number gen id=_n // Prepare to mark years on x-axis nicely local endyear=year($today) gen temp=year(start) sum temp local startyear=`r(min)' local startdate=date("1/1/`startyear'","MDY",2050) local enddate=date("12/21/`endyear'","MDY",2050) local xlabels "" forval y=`startyear'/`endyear' { local ymid=date("7/1/`y'","MDY",2050) local xlabels `"`ymid' "`y'" `xlabels'"' display `"`xlabels'"' } local xlabelcommand `"xlabel(`startdate'(365)`enddate', nolabel) xmlabel(`xlabels', notick labsize(small))"' // ===================== // MAKE THE CHART #delimit ; // Translate a date into Stata-date to mark time points local line1=date("6/1/14","MDY",2050); twoway (rspike start end id, horizontal lcol(gs4) lpattern(dash)) (scatter id start, mcolor(black) msymbol(Oh)) (scatter id fpres, mcolor(blue) msymbol(Th)) (scatter id fsub, mcolor(green) msymbol(Sh)) (scatter id frr, mcolor(orange) msymbol(Dh)) (scatter id accept, mcolor(black) msymbol(O)) , scheme(s1color) legend(pos(6) cols(3) order(2 3 4 5 6) label(2 "Approx. Start") label(3 "First Presentation") label(4 "First Submission") label(5 "First R&R") label(6 "Acceptance") region(style(none)) ) xtitle("Date") ytitle("") ylabel(none) `xlabelcommand' xline(`line1', lcolor(gs8) lpattern(dot)) plotregion(style(none)) yscale(noline) xscale(noline) ; #delimit cr // ===================== // Export the figure graph export "${figout}/timeline.png", as(png) replace