mcguinlu / robvis

A package to quickly visualise risk-of-bias assessment results
https://mcguinlu.github.io/robvis/
Other
58 stars 22 forks source link

Domains caption overlapping with the Judgement legend #148

Open befriendabacterium opened 8 months ago

befriendabacterium commented 8 months ago

Describe the bug

When you make the plot too narrow (desirable for aesthetic reasons to reduce whitespace), the Domains caption and Judgement legends overlap. See screenshot.

To Reproduce

library(robvis)
data(data_rob2)

# Generate larger dataset
data <- rbind(data_rob2, data_rob2)
data$Study <- paste("Study",seq(1,18))

# Plot with reduced point size
test<-rob_traffic_light(data, tool = "ROB2", psize = 10)
ggsave(test, file='rob2_test.tiff', height = 12, width=3)

And observe the outputted plot.

Expected behavior This is sort of expected, but it can make it tricky to limit whitespace when you have a lot of studies whilst also preventing overlap of the Domains caption and Judgement legend. One option to make it a bit more versatile would be to push the Domain caption to the lwft edge of the Study labels rather than placing it at the left edge of the traffic lighted area. Alternatively, the font size auto-adjusts to the plot dimensions but i've no idea how that'd work.

Screenshots image

Desktop (please complete the following information):

Additional context As a temporary workaround, you can add a line to your ggplot object to push the Domain caption further left and/or reduce font size:

data <- rbind(data_rob2, data_rob2)
data$Study <- paste("Study",seq(1,18))

# Plot with reduced point size
test<-rob_traffic_light(data, tool = "ROB2", psize = 10)+
      theme(plot.caption.position = "plot",
            plot.caption = element_text(hjust = 0, size=8))

ggsave(test, file='rob2_test.tiff', height = 12, width=3)
mcguinlu commented 6 months ago

Hi @befriendabacterium,

Thanks for this issue too!

Yes, this is a tricky problem to solve, and to be honest, the best approach I have found is to leave it up to the user to reduce the font size/move the domain names. I personally don't like that the legend is not aligned with the edge of the plot but rather with the edge of the "Study" axis label, but it is definitely a personal preference!

rob2_test

Somewhat relatedly, the development version of robvis contains a function called rob_save() which tries to use some information about the plots to set reasonable defaults for the width/height when writing the file out. However, this function does not account for legend text size.

One other option would be to include an argument to "stack" the domain names and judgement labels, that users could specify if they wanted a narrow plot?

befriendabacterium commented 6 months ago

Hi Luke,

Cool thanks for clarifying. Yes, a tricky one. I'll just stick to my manual fix for now then. Will leave it up to you as to whether you wanna close this or not!

Cheers Matt

P.S. robsave seems to perform pretty well too - thanks for flagging!