asjadnaqvi / stata-alluvial

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

-showtotal- total to be placed on second row of label #6

Open mkaulisch opened 1 year ago

mkaulisch commented 1 year ago

In my recoded example: `clear input double impact_p byte(field period) 3410.16666666667 3 1 4588.83333333333 3 7 5502.33333333333 3 12 365.166666666667 4 1 543 4 7 628.833333333333 4 12 160.5 5 1 136.333333333333 5 7 172.5 5 12 875.166666666667 6 1 1019.33333333333 6 7 1114.33333333333 6 12 147 7 1 374.5 7 7 524 7 12 end label values field l_field_kurz label def l_field_kurz 3 "BHS", modify label def l_field_kurz 4 "LES", modify label def l_field_kurz 5 "MCS", modify label def l_field_kurz 6 "PSE", modify label def l_field_kurz 7 "SSH", modify label values period l_period label def l_period 1 "2006–2009", modify label def l_period 7 "2012–2015", modify label def l_period 12 "2017–2020", modify label var impact_p "Anzahl Publikationen" label var field "Fächergruppe" label var period "Auswertungszeitraum"

**# Generate an identifier variable gen id = field

**# reshape into wide format reshape wide impact_p, i(id) j(period)

**# Expand by largest number expand impact_p12, gen(expand_p12_i)

**# Field as content

**# Period 7 gen field_p7 = field_p12 if f_p12_r <= round(impact_p7)

**# Period 1 gen field_p1 = field_p12 if f_p12_r <= round(impact_p1)

**# label la val field_p1 field_p7 l_field_kurz

la var field_p1 "2006-2009" la var field_p7 "2012-2015" la var field_p12 "2017-2020"

**# alluvial plot alluvial field_p1 field_p7 field_p12, /// showmiss showtotal /// name(alluv_test1, replace)`

the use of -showtotal- get the labels to overlap. This is due to the low share of certain categories. It would be cooler to enhance the area fill for the category label and put the total into a second row.