insightsengineering / tern

Table, Listings, and Graphs (TLG) library for common outputs used in clinical trials
https://insightsengineering.github.io/tern/
Other
77 stars 22 forks source link

[Feature Request]: g_lineplot: Allow users to control the relative height of the plot vs. table sections #1334

Open kathrinflunkert opened 1 month ago

kathrinflunkert commented 1 month ago

Feature description

It looks like tern renders the relative height of the plot/table sections using cowplot::plot_grid that has rel_heights argument defaulted to 1 (i.e. both sections are of the same height). The tern::g_lineplot function simply uses the default with no way to control it. This leads to very unfortunate layouts when e.g. there is only one arm to display. It would be good if the user could decide if there should indeed be a 1:1 ratio for the plot and the table space or rather 2:1, 3:1 etc.

Example:

library(chevron)
library(dplyr)

data <- syn_data

data$adlb <- data$adlb %>% 
  filter(ACTARM == 'A: Drug X') 
data$adlb$ACTARM <- droplevels(data$adlb$ARM)

data$adsl <- data$adsl %>% 
  filter(ACTARM == 'A: Drug X')
data$adsl$ACTARM <- droplevels(data$adsl$ARM)

run(mng01, data, dataset = "adlb",  table = c("n", "mean"))

Result:

image

Code of Conduct

Contribution Guidelines

Security Policy