-
-
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
809f734
commit 150c982
Showing
5 changed files
with
53 additions
and
36 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
v 1.5 | ||
d STREAMPLOT: A package for creating streamplots in Stata | ||
v 1.51 | ||
d STREAMPLOT: A package for creating stream plots in Stata | ||
d | ||
d Asjad Naqvi, | ||
d [email protected] | ||
d | ||
d Distribution-Date: 20230528 | ||
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,12 +1,13 @@ | ||
*! streamplot v1.5 (20 Nov 2022) | ||
*! streamplot v1.51 (28 May 2023) | ||
*! Asjad Naqvi ([email protected]) | ||
|
||
* v1.5 (20 Nov 2022): recenter option added. improved variable precision. | ||
* v1.4 (08 Nov 2022): Major code cleanup and some parts reworked. Observation checks. Palette options. label controls. | ||
* v1.3 (20 Jun 2022). Add marker labels and format options | ||
* v1.2 14 Jun 2022: passthru optimizations. error checks. reduce the default smoothing. labels fix | ||
* v1.1 08 Apr 2022 | ||
* v1.0 06 Aug 2021 | ||
* v1.51 (28 May 2023): Clean up labcond and offset changes to percentages. | ||
* v1.5 (20 Nov 2022): recenter option added. improved variable precision. | ||
* v1.4 (08 Nov 2022): Major code cleanup and some parts reworked. Observation checks. Palette options. label controls. | ||
* v1.3 (20 Jun 2022): Add marker labels and format options | ||
* v1.2 (14 Jun 2022): passthru optimizations. error checks. reduce the default smoothing. labels fix | ||
* v1.1 (08 Apr 2022) | ||
* v1.0 (06 Aug 2021) | ||
|
||
********************************** | ||
* Step-by-step guide on Medium * | ||
|
@@ -25,9 +26,9 @@ program streamplot, sortpreserve | |
|
||
version 15 | ||
|
||
syntax varlist(min=2 max=2 numeric) [if] [in], by(varname) [palette(string) alpha(real 100) smooth(real 3)] /// | ||
[ LColor(string) LWidth(string) labcond(string) ] /// | ||
[ YLABSize(string) YLABel(varname) YLABColor(string) offset(real 0.12) droplow ] /// | ||
syntax varlist(min=2 max=2 numeric) [if] [in], by(varname) [palette(string) alpha(real 100) smooth(real 3) ] /// | ||
[ LColor(string) LWidth(string) labcond(real 0) ] /// | ||
[ YLABSize(string) YLABel(varname) YLABColor(string) offset(real 15) droplow ] /// | ||
[ xlabel(passthru) xtitle(passthru) title(passthru) subtitle(passthru) note(passthru) scheme(passthru) name(passthru) xsize(passthru) ysize(passthru) ] /// | ||
[ PERCENT FORMAT(string) RECenter(string) ] | ||
|
||
|
@@ -43,15 +44,14 @@ version 15 | |
capture findfile labmask.ado | ||
if _rc != 0 { | ||
qui ssc install labutil, replace | ||
exit | ||
} | ||
|
||
marksample touse, strok | ||
gettoken yvar xvar : varlist | ||
|
||
|
||
* Definition of locals - Default format | ||
if `"`format'"' == "" local format "%12.0f" | ||
if `"`format'"' == "" local format "%12.0fc" | ||
|
||
|
||
|
||
|
@@ -60,6 +60,8 @@ preserve | |
|
||
keep if `touse' | ||
|
||
isid `varlist' `by' // duplicates check | ||
|
||
gen ones = 1 | ||
bysort `by': egen counts = sum(ones) | ||
egen tag = tag(`by') | ||
|
@@ -145,7 +147,7 @@ preserve | |
summ `xvar' if ``yvar'_ma7' != ., meanonly | ||
|
||
local xrmin = r(min) | ||
local xrmax = r(max) + ((r(max) - r(min)) * `offset') | ||
local xrmax = r(max) + ((r(max) - r(min)) * (`offset' / 100)) | ||
|
||
*cap drop stack_`yvar' | ||
|
||
|
@@ -260,23 +262,24 @@ drop lastsum* | |
|
||
foreach x of numlist 1/`items' { | ||
|
||
if "`labcond'" != "" { | ||
local condition "& `yvar'`x' `labcond'" | ||
} | ||
else { | ||
local condition | ||
} | ||
|
||
* Addition of percent and format (Marc Kaulisch) | ||
if `"`percent'"'!="" { | ||
local ylabvalues `"string(`yvar'`x'_share, `"`format'"') + "%""' | ||
|
||
local labvar `yvar'`x'_share | ||
|
||
} | ||
else { | ||
local ylabvalues `"string(`yvar'`x', `"`format'"')"' | ||
|
||
local labvar `yvar'`x' | ||
} | ||
|
||
di "`labvar'" | ||
|
||
local t : var lab `yvar'`x' | ||
gen label`x'_`yvar' = "`t'" + " (" + `ylabvalues' + ")" if last==1 `condition' // | ||
gen label`x'_`yvar' = "`t'" + " (" + `ylabvalues' + ")" if last==1 & `labvar' >= `labcond' | ||
|
||
} | ||
|
||
|
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