kellirichardson / biofeedback-vis

Interactive Sankey diagram for biofeedback scoping review
MIT License
4 stars 0 forks source link

Spacing of nodes code #34

Closed kellirichardson closed 2 years ago

kellirichardson commented 2 years ago

Hey @Aariq ! I was looking through the code we have, and I am not seeing where you were able to get the node labels to space out/not overlap. Did you use code for this? If so, would this code work on a static sankey? (Thinking about the smaller sankey we are presenting in our manuscript).

Aariq commented 2 years ago

It's here: https://github.com/cct-datascience/biofeedback-vis/blob/d956dfb3ccb3a8279359f8b8d8dfe19d023c6035/app/app.R#L43

It didn't actually have anything to do with the ggplot code, but rather the space the plot was allowed to take up in the Shiny app.

Aariq commented 2 years ago

Feel free to adjust the height, but I'd leave the width at "100%" so the plot just fills the width of the browser window. You could try making the height a % instead of a pixel value (e.g. "80%" instead of "600px"), but just make sure you check what happens when you resize your window---the percentage is the percent of the browser window total height, I think.

kellirichardson commented 2 years ago

Thank you! The spacing looks great on the interactive sankey we have here! We are including a static sankey (much smaller) in our manuscript, so I was going to see if the code you used for spacing could be used in the static sankey as well!

Aariq commented 2 years ago

Ooh, so I think just changing the dimensions of the plot to make it taller should help. If you save the plot with ggsave() you can do this fairly easily. E.g. to save a plot that's 10x5 inches as a .png:

p <- ggplot(.... code to make plot

ggsave("myplot.png", p, width = 10, height = 5, units = "in")

You might have to also make the labels smaller for it to look good. I'd be happy to help with that if you get stuck.

kellirichardson commented 2 years ago

That worked!!! Thank you!

Two additional questions that I am struggling with (only if they are easy to answer):

  1. Do you know if there is a way to order from "largest" to "smallest"? For instance, in the figure below (don't mind the colors), it would be useful to have the theories in order to show which theories are most used in biological feedback literature.
  2. I used hjust = 1.1 to get the labels to go to the left. Do you know if it is possible to hjust the Domain labels to go to the left, but the Theory labels to go to the right?

I am happy to come to office hours as well for these additional questions!

myplot2