Announcement

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

  • how to add labels of the nodes using sankey_plot command in stata?


    Hi. I am having trouble labeling the nodes...

    I want to label the values at each node. However it does not showing up. My command is
    gen x0 = 1 gen x1 = 2
    contract x0 x1 A B, freq(freq2)
    sankey_plot x0 A x1 B, ///
    width0(freq2) ///
    extra adjust ///
    colorpalette(viridis, opacity(40)) ///
    gap(0.1) noline ///
    xlabel(1 "A" 2 "B", nogrid)

    A represents the first node and B represents the second node.
    But it turns out nothing.

    So I add label0(A) label1(B) in the command, but it gives me an error code" variable A not found r(111); "

    Anyone can help me?

    Thank you in advance!
    Click image for larger version

Name:	Graph.png
Views:	1
Size:	334.4 KB
ID:	1715628

    Last edited by Shinyae Noh; 31 May 2023, 06:48.

  • #2
    I think what you need to do is label all the values of variables A and B
    the command should pick them up and use them in the figure

    Comment


    • #3
      Thank you FernandoRios! I've referred to your method a lot.

      Back to the question, all values of A and B are already labeled... and I am so curious that sankey_plot with wide options works well, and nodes are well labeled.

      Comment


      • #4
        Excellent!
        I ll check again what is going on with the labels in the other case. But right now have limited access to a desktop.
        if you follow my site tho, I ll post the update there
        best wishes

        Comment

        Working...
        X