0

I want to create a sankey that describes whether people are retained in care, lost to follow up, died or censored at each year after they started treatment. I have created the diagram but the buckets at each time point get larger/ taller from left to right.
This is my code:

ret_pharm_sankey_5yearall <- sankeyNetwork(Links = retention_pharm_sankey_5yrall_df, Nodes = retention_nodes,
                                           Source = "IDsource", Target = "IDtarget",
                                           Value = "time_year", NodeID = "name", 
                                           colourScale = my_colour, 
                                           LinkGroup = "group", 
                                           NodeGroup="group", 
                                           iterations = 0,  #this uses the order in nodes dataframe
                                           sinksRight=FALSE)

What I want: I want it to remain a constant height, reflecting the consistent number of individuals, over time What I've tried:

  1. I have tried setting sinksRight to true/false and it doesnt help.
  2. tried this from chat gpt:
# Add CSS styling to set constant height
ret_pharm_sankey_5yearall <- onRender(ret_pharm_sankey_5yearall, '
  function(el, x) {
    d3.select(el).select("svg").style("height", "500px");
  }
')

What I get: Sankey diagram of RIC

If more helpful to see it visually, i want the Sankey to be a consistent width representing a constant number of people, like this: example of what I want the Sankey to look like

instead of this: Sankey diagram of RIC that I produce (which starts small and grows larger, despite containing a consistent number of individuals at each time point)

Rookie
  • 1
  • 1
  • It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. – MrFlick May 17 '23 at 14:14
  • Hi there. Sorry, I tried to give an example but I think its less about the data and more about a setting - tried to explain better visually. Let me know if that doesnt help make it clearer! – Rookie May 23 '23 at 21:41

0 Answers0