Announcement

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

  • Sankey plot: separate scale for the right/left side

    Hello Stata users,

    I would be grateful for any assistance.

    I employed the following syntax to generate a Sankey plot.
    Code:
    sankey x if shock!="." & copem!=".", from(shock) to(copem) by(y) labposition(100) labangle(35) labc(black) labsize(3) boxw(5) valsize(1) ctitles("{stSerif:{bf:HH affected by:}}" "{stSerif:{bf:Coped with shock by:}}") ctpos(top)  ctg(10) cts(3) smooth(7) sort1(name) format(%12.0f) recenter(mid) labscale(0.2) labprop percent valscale(0.5) valprop
    Then I get this graph:
    Click image for larger version

Name:	percent.png
Views:	1
Size:	322.4 KB
ID:	1737326

    The percentage of each option on the right is shown on the same/common scale as on the left. Therefore, they appear so small that it is difficult to identify and compare the lobes on the right side relative to each other. I need your help so that the shares on the right side are shown in a separate scale.


    Your guidance on resolving these issues is highly appreciated.

    Best regards,
    Dastan

  • #2
    I haven't used sankey (from SSC?). What are the original data here? An 8 x 10 table, or something else? Why are values so much bigger on one side than on the other?

    The author Asjad Naqvi asks people to raise issues on GitHub. Perhaps you've done that.

    Comment


    • #3

      Maybe the alluvial -Package is more appropriate in your use case. https://github.com/asjadnaqvi/stata-alluvial

      Comment


      • #4
        Thank you Nick Cox!

        Dastan Aseinov, something is off with the figure. If the inflows and the outlows are fully balanced, then the bars should be the same height. Maybe you are using the "percent" option to show percentages? This is a beta option to test additional variations and I do not recommend using it. If you want to show percentages rather than actual values then calculate these directly and then use the standard sankey option.

        Alternatively, you can use the "Alluvial" package as Marc Kaulisch suggested which is exactly designed for the type of visualization you are trying to generate.

        Additional note: there is no left and right in Sankey. There can be one layer with a start and end destinations. So a request for rescaling one axis means adding the ability to rescale n number of layers. This is a dangerous step since it can lead to mis-representing data and this won't be implemented.

        Comment

        Working...
        X