asjadnaqvi / stata-alluvial

A Stata package for alluvial plots
MIT License
5 stars 3 forks source link

Add option to control share vs value. Add option to control brackets display. #15

Open ericmelse opened 1 year ago

ericmelse commented 1 year ago

Dear Asjad, it is really helpful that it is possible to extend the title of the categories by their total, either as nominal values or shares (fractions), like:

sysuse nlsw88.dta, clear
label define racelbl 3 ".    O", modify
fre race
alluvial race married collgrad smsa union, palette(CET C7) labs(*1.4) showtot boxw(*16) shares vals(*1.2) valf(%12.2f) 

which results in: Alluvial_test_1_20230418 Your command adds the value between bracket, like: Black (0.27), which is fine for most purposes. However, I suggest an option to be able to control how this is done. For example without brackets but using a comma or en dash or em dash or straight brackets, like Black, 0.27 Black – 0.27 Black — 0.27 Black [0.27] To do this in a most generic manner, maybe something like this is possible:

valuesep(str)
Option to set the seperator of the displayed value of the categories, which is defined between "". Default is valuesep(" ") for only a space. 

valuebrace(str)
Option to set the brace characters around the displayed value of the categories, which is defined between "". Default is valuebrace("()") for round brackets. 

Another suggestion is an option to set (toggle) the exclusion of the preceding zero (which I find rather redundant), like: Black, .27 Black — .27 Black [.27] to conserve space used in the plot. Possibly set as an option, like:

nosharezero
Option to disable the display of the leading zero of the displayed share values of the categories.