Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Display frequency with sankey_plot

    Hi ,
    I am using the 'wide' option with the sankey_plot function. Below is the code for producing the sankey plot. However, I am encountering two issues:
    1. I would like to display the frequency from the 'fq' variable on each node as a label. Is there a way to accomplish this and have it visible over the graph?
    2. In the command's help documentation, an option is mentioned as 'color(varname)' to preassign colors based on a specified variable. However, this option does not seem to be functioning .
    Could anyone please provide assistance with these matters?

    ***
    contract dist_dhq lhw_engage anc4 pob if survey==2 & age_grp==0 , freq(fq) percent(pr)

    sankey_plot dist_dhq lhw_engage anc4 pob , wide width(pr) ///
    colorpalette(viridis, opacity(40)) labcolor(black) labsize(small) ///
    xlabel(1 "Distance to DHQ" 2 "LHW engagement" 3 "ANC Visits" 4 "Place of birth" , labsize(small) nogrid ) gap(0.1) tight ///
    plotregion(margin(large))

  • #2
    Hi there
    for point 1. The only way to do that would be to add the percentage into the label
    something like this:

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str17 married str12 pet str9 happy byte freq
    "Married:Yes 12/15" "Pet:Yes 9/12" "Happy:Yes" 5
    "Married:Yes 12/15" "Pet:Yes 9/12" "Happy:Yes" 4
    "Married:Yes 12/15" "Pet:No 3/12"  "Happy:Yes" 3
    "Married:No 3/15"   "Pet:Yes 2/15" "Happy:Yes" 2
    "Married:No 3/15"   "Pet:No 1/15"  "Happy:No"  1
    end
    and then Run your code

    For the second question. Need too look into the potential bug. May be easy to fix, but will need time. Sorry for that.

    Comment


    • #3
      Thank you very much for the response.

      Comment

      Working...
      X