-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d77805a
commit 1d75fab
Showing
7 changed files
with
57 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
v 1.7 | ||
v 1.81 | ||
d STREAMPLOT: A package for creating stream plots in Stata | ||
d | ||
d Asjad Naqvi, | ||
d [email protected] | ||
d | ||
d Distribution-Date: 20240401 | ||
d Distribution-Date: 20240430 | ||
d | ||
d https://medium.com/the-stata-guide | ||
d https://github.com/asjadnaqvi/Stata-schemes | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
*! streamplot v1.8 (25 Apr 2024) | ||
*! streamplot v1.81 (30 Apr 2024) | ||
*! Asjad Naqvi ([email protected]) | ||
|
||
* v1.81 (30 Apr 2024): added area option to creat | ||
* v1.8 (25 Apr 2024): added labscale option. Added percent/share as substitutes. more flexible for generic options. | ||
* v1.7 (01 Apr 2024): trendline, yline, drop if by() is missing | ||
* v1.61 (15 Jan 2024): fixed wrong locals. changed ylab to just lab. | ||
|
@@ -27,7 +28,7 @@ version 15 | |
[ NOLABel nodraw ] /// v1.5x | ||
[ cat(varname) YREVerse ] /// // v1.6 | ||
[ tline TLColor(string) TLWidth(string) TLPattern(string) droplow ] /// // v1.7 | ||
[ * labprop labscale(real 0.3333) percent share ] // 1.8 options | ||
[ * labprop labscale(real 0.3333) percent share area ] // 1.8 options | ||
|
||
|
||
// check dependencies | ||
|
@@ -82,8 +83,8 @@ preserve | |
collapse (sum) `yvar', by(`xvar' `by' `cat') | ||
|
||
|
||
gen ones = 1 | ||
bysort `by': egen counts = sum(ones) | ||
gen _ones = 1 | ||
bysort `by': egen counts = sum(_ones) | ||
egen tag = tag(`by') | ||
summ counts, meanonly | ||
|
||
|
@@ -106,7 +107,7 @@ preserve | |
exit | ||
} | ||
|
||
drop ones tag counts | ||
drop _ones tag counts | ||
|
||
fillin `by' `xvar' | ||
recode `yvar' (.=0) | ||
|
@@ -175,6 +176,15 @@ preserve | |
|
||
|
||
replace `yvar' = 0 if `yvar' < 0 // this is technically wrong but we do it anyways // fix in later versions | ||
|
||
|
||
if "`area'" != "" { | ||
bysort `xvar': egen double _sum = sum(`yvar') | ||
replace `yvar' = (`yvar' / _sum) * 100 | ||
drop _sum | ||
} | ||
|
||
|
||
tssmooth ma _ma = `yvar' , w(`smooth' 1 0) | ||
|
||
// add the range variable on the x-axis | ||
|
@@ -199,7 +209,6 @@ preserve | |
} | ||
|
||
|
||
|
||
** preserve the labels for use later | ||
|
||
local mylab: value label `by' | ||
|
@@ -272,6 +281,12 @@ preserve | |
} | ||
|
||
|
||
if "`area'" != "" { // overwrite | ||
cap drop _meanval | ||
gen _meanval = 0 | ||
} | ||
|
||
|
||
|
||
foreach x of varlist _stack* { | ||
gen double `x'_norm = `x' - _meanval | ||
|
@@ -281,9 +296,6 @@ preserve | |
|
||
// this part is for the mid points | ||
|
||
*summ `xvar' | ||
*gen last = 1 if `xvar'==r(max) | ||
|
||
gen double _ylab = . | ||
gen double _yval = . | ||
gen double _yshare = . | ||
|
@@ -316,7 +328,7 @@ preserve | |
summ `xvar', meanonly | ||
gen _xlab = r(max) if _yval!=. | ||
|
||
**** automate this part | ||
**** automate this part | ||
|
||
|
||
ds _stack*norm | ||
|
@@ -325,7 +337,7 @@ preserve | |
|
||
|
||
if "`format'" == "" { | ||
if "`percent'"=="" & "`share'"=="" { | ||
if "`percent'"=="" & "`share'"=="" & "`area'"=="" { | ||
local format %15.0fc | ||
} | ||
else { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters