Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Domains caption overlapping with the Judgement legend #148

Open
befriendabacterium opened this issue Feb 14, 2024 · 2 comments
Open

Domains caption overlapping with the Judgement legend #148

befriendabacterium opened this issue Feb 14, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@befriendabacterium
Copy link

befriendabacterium commented Feb 14, 2024

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):

  • OS: Windows 10
  • Interface: RStudio/R/robvis
  • Version: "Mountain Hydrangea" 2023.06.1 Build 524/4.3.1/CRAN version of robvis

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
Copy link
Owner

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
Copy link
Author

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants