Skip to content

Instantly share code, notes, and snippets.

@docsteveharris
Created April 2, 2013 15:42
Show Gist options
  • Save docsteveharris/5293223 to your computer and use it in GitHub Desktop.
Save docsteveharris/5293223 to your computer and use it in GitHub Desktop.
overlapping labels in slope graphs in stata
// try and handle labels over-writing by altering the label position
// pos_gap is a variable that controls how close two labels must be before the position is changed
// it can only handle a series of 3 overlapping labels
// the first is assigned up a clock position
// the second is assigned down a clock positon
local pos_gap 0.1
bys this_icode (percent): replace pos = pos + 1 ///
if abs(percent[_n] - percent[_n+1]) < `pos_gap' ///
& pos[_n] == pos[_n+1]
bys this_icode (percent): replace pos = pos - 1 ///
if abs(percent[_n] - percent[_n-1]) < `pos_gap' ///
& pos[_n] == pos[_n-1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment