1

i am trying to create sankey diagram using below data set

my.data = data.frame(Married = c("Yes","Yes", "Yes", "No", "No"),
Pet = c("Yes", "Yes", "No", "Yes", "No"),
Happy = c("Yes", "Yes", "Yes", "Yes", "No"),
freq = 5:1)

I created the sankey plot using

library(flipPlots)
SankeyDiagram(my.data[, -4],
link.color = "Source", 
weights = my.data$freq) 

the problem is that i want to keep the color of ribbon same from start to end i.e the ribbon color from source remain the same till the last node i.e happy and dont change after passing from pet

thanks in advance

Mark
  • 7,785
  • 2
  • 14
  • 34
Aisha Ali
  • 11
  • 1
  • Hi Aisha, Welcome to Stack Overflow. This is a link that allows for custom colors in ggsankey for Sankey plots; it uses `scale_fill_manual()`. It's about 2/3rds of the way down: https://rpubs.com/techanswers88/sankey-with-own-data-in-ggplot – David Jul 08 '23 at 17:11
  • thank you so much David for your comment but when i run the code all ribbons became greyish – Aisha Ali Jul 08 '23 at 18:28
  • Hi Aisha, you are almost there. The default for `scale_fill_manual` is to use a greyish ribbon color. You have to specify a bit more in `scale_fill_manual`. If you search that page on this: `="red"`, you will see examples on how to fill in the arguments to `scale_fill_manual(values = c(AishasColors))` (between the parentheses) that allow you to customize your colors. – David Jul 08 '23 at 18:56
  • thank you David for your response and help – Aisha Ali Jul 09 '23 at 07:25

0 Answers0