Home > Blockchain >  Reduce unwanted space in facet wrapped multi plot in R ggplot2
Reduce unwanted space in facet wrapped multi plot in R ggplot2

Time:01-18

I have the following image obtained from the code provided below. I need to reduce the plot size by removing unwanted space which I have marked in teal circles. Note that, I need the remaining be kept in the same arrangement with the same font size. I tried setting the panel spacing which does not give what I exactly need.

In other words, I need to narrow the width of zebra strips.

enter image description here

library(readxl)
library(dplyr)
library(lubridate)
library(grid)

min = 0
max = 1.05

sim_results_conf_int <- dput(sim_results_conf_int)
structure(list(Model = c(1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 
1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 
1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3), `Mean of Estimated effect` = c(-0.00027761952121, 
-0.00027551011815, -0.000714081146458, 0.000138653774321, 0.000119077874792, 
0.06537576055, 0.000128130591427, 6.993505595e-05, 0.11653407498, 
-0.000121345755422, -0.00014125753372, 0.0143126275335, -0.00040669041783, 
-0.000567724424589, 0.00011365028616, -0.0003397864755121, -0.000457468711809, 
0.06967839165, -6.78340827e-05, -0.000478993169466, 0.12495252232, 
-0.00013044560631, -0.00021988662185, 0.0160719685202, -0.000505470710676, 
-0.000180426708081, -5.0976383562e-05, 0.000269610057977, 9.354964844e-05, 
0.07184994794, 0.0002098391238, 0.00045822041994, 0.12485673058, 
8.658344089e-05, 0.000169415832933, 0.01610380257945, -0.00032090324511, 
0.0001094633691543, 5.894687788e-05, 0.000240501348501, 0.000140737935046, 
0.10060236794, 8.5708527847e-05, 7.137664979e-05, 0.1612029216, 
-0.000125446473491, 4.9950335379e-05, 0.025663675899), `SE of Estimated effect` = c(0.000397633811001549, 
0.000397559127530463, 0.000387493036422049, 0.000408633449654691, 
0.000408393580877182, 0.000643906355622298, 0.000466205877910809, 
0.000467629013084495, 0.000996770657978013, 0.000383814695932682, 
0.000384346986188387, 0.000397657633891764, 0.000346859184622338, 
0.000357224780969225, 0.000371655912271575, 0.000374729136278765, 
0.000379361768610034, 0.000630419159262826, 0.000436768335382745, 
0.000433356756889939, 0.00105161414064621, 0.000355789713816859, 
0.000363626061785186, 0.000414805470916461, 0.00033781392591644, 
0.00030934517374657, 0.000315618453356872, 0.000385560736191996, 
0.000365144491024794, 0.000655690612854308, 0.000428091302436967, 
0.000414102533344379, 0.00103555522145669, 0.000349708476229177, 
0.000332881675289401, 0.000359753696490732, 0.000208466151189535, 
0.000210074769251167, 0.000204487167980701, 0.000286619966081066, 
0.000283112736458343, 0.000808302610105675, 0.000342407236610156, 
0.000363305970555189, 0.00124073661693357, 0.000228580599703133, 
0.000233667182917512, 0.000309762634119863), `Mean(-log(p-value))` = c(0.447546074777396, 
0.447075881302285, 0.450954008527722, 0.499268140649132, 0.499231748841211, 
7.91057953499336, 0.569555344510371, 0.572657459582211, 23.0760393146412, 
0.442671100658129, 0.443349315175396, 0.913663720531189, 0.427323942903927, 
0.427035177323113, 0.435843697737576, 0.472544375975444, 0.463507824681231, 
9.85940962060964, 0.589511279790337, 0.574405210947712, 28.2388870234011, 
0.43731296583704, 0.438466131865898, 1.03610437949704, 0.440056674067033, 
0.434657408167099, 0.424669555637539, 0.499655548016483, 0.513929160490333, 
12.3292114042, 0.580250960649736, 0.596568730964983, 34.4317112098218, 
0.461507323415263, 0.460993706801582, 1.20432788246295, 0.431081073646729, 
0.432010535530157, 0.42597367327709, 0.624502585449497, 0.613653139717795, 
47.2421595108874, 0.766994366347734, 0.769298244049813, 110.243052837211, 
0.47494899968092, 0.489693429310453, 4.23872775599795), `SE(-log(p-value))` = c(0.0145885092410472, 
0.0145765256328736, 0.0143012057664245, 0.0162565695873009, 0.0161876478066293, 
0.0856051523337243, 0.0188244311705022, 0.0189224888013473, 0.160355369378673, 
0.0137326212533724, 0.0137271725774574, 0.0256323701291776, 0.0135026264887096, 
0.0145370932841137, 0.0141990754425992, 0.0150340479057503, 0.0144785203065801, 
0.0996438284128827, 0.0194988594031488, 0.019139474206366, 0.188250935696704, 
0.0137260619923085, 0.013746111228876, 0.0279706706773484, 0.0146435281370058, 
0.0137121043660758, 0.013850784811562, 0.015964949251676, 0.0163830816011049, 
0.108274049530958, 0.0183562365716799, 0.0186161781564205, 0.202888972869083, 
0.0145520536866768, 0.0145817334409652, 0.0299021295952775, 0.0136707414296784, 
0.0135464474798857, 0.0135257277754481, 0.0214588027247813, 0.0206202856108384, 
0.23764129682392, 0.0273873736464843, 0.0257238820018326, 0.38062195055277, 
0.0153647435393976, 0.0153877687438883, 0.0612778923336589), 
    `Var G` = c(0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 
    0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 
    0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 
    0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 
    0.4, 0.4, 0.4), `Var G_E` = c(0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 
    0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 
    0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 
    0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 
    0.5, 0.5, 0.5, 0.5, 0.5, 0.5), `Var GxE` = c(0, 0, 0, 0.05, 
    0.05, 0.05, 0.1, 0.1, 0.1, 0.01, 0.01, 0.01, 0, 0, 0, 0.05, 
    0.05, 0.05, 0.1, 0.1, 0.1, 0.01, 0.01, 0.01, 0, 0, 0, 0.05, 
    0.05, 0.05, 0.1, 0.1, 0.1, 0.01, 0.01, 0.01, 0, 0, 0, 0.05, 
    0.05, 0.05, 0.1, 0.1, 0.1, 0.01, 0.01, 0.01), `Cov between G and G_E` = c(0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.4, 0.4, 0.4, 0.4, 0.4, 
    0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 
    0.4, 0.4, 0.4), `Res Var of y` = c(0.5, 0.5, 0.5, 0.5, 0.5, 
    0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 
    0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 
    0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 
    0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5), `Res Var of E` = c(0.5, 
    0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 
    0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 
    0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 
    0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5), `Cov Res of y and E` = c(0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 
    0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 
    0.4, 0.4, 0.4), `Mean Type 1 Err` = c(0.054, 0.054, 0.058, 
    0.072, 0.07, 1, 0.111, 0.114, 1, 0.05, 0.048, 0.258, 0.052, 
    0.055, 0.059, 0.071, 0.06, 1, 0.116, 0.109, 1, 0.044, 0.047, 
    0.312, 0.054, 0.045, 0.052, 0.073, 0.086, 1, 0.102, 0.118, 
    1, 0.063, 0.059, 0.386, 0.057, 0.049, 0.048, 0.121, 0.123, 
    1, 0.169, 0.189, 1, 0.062, 0.069, 0.965), `95% CI` = c("(0.0402159512479098, 0.0677840487520902)", 
    "(0.0402159512479098, 0.0677840487520902)", "(0.0442159512479098, 0.0717840487520902)", 
    "(0.0582159512479098, 0.0857840487520902)", "(0.0562159512479098, 0.0837840487520902)", 
    "(0.98621595124791, 1.01378404875209)", "(0.0972159512479098, 0.12478404875209)", 
    "(0.10021595124791, 0.12778404875209)", "(0.98621595124791, 1.01378404875209)", 
    "(0.0362159512479098, 0.0637840487520902)", "(0.0342159512479098, 0.0617840487520902)", 
    "(0.24421595124791, 0.27178404875209)", "(0.0382159512479098, 0.0657840487520902)", 
    "(0.0412159512479098, 0.0687840487520902)", "(0.0452159512479098, 0.0727840487520902)", 
    "(0.0572159512479098, 0.0847840487520902)", "(0.0462159512479098, 0.0737840487520902)", 
    "(0.98621595124791, 1.01378404875209)", "(0.10221595124791, 0.12978404875209)", 
    "(0.0952159512479098, 0.12278404875209)", "(0.98621595124791, 1.01378404875209)", 
    "(0.0302159512479098, 0.0577840487520902)", "(0.0332159512479098, 0.0607840487520902)", 
    "(0.29821595124791, 0.32578404875209)", "(0.0402159512479098, 0.0677840487520902)", 
    "(0.0312159512479098, 0.0587840487520902)", "(0.0382159512479098, 0.0657840487520902)", 
    "(0.0592159512479098, 0.0867840487520902)", "(0.0722159512479098, 0.0997840487520902)", 
    "(0.98621595124791, 1.01378404875209)", "(0.0882159512479098, 0.11578404875209)", 
    "(0.10421595124791, 0.13178404875209)", "(0.98621595124791, 1.01378404875209)", 
    "(0.0492159512479098, 0.0767840487520902)", "(0.0452159512479098, 0.0727840487520902)", 
    "(0.37221595124791, 0.39978404875209)", "(0.0432159512479098, 0.0707840487520902)", 
    "(0.0352159512479098, 0.0627840487520902)", "(0.0342159512479098, 0.0617840487520902)", 
    "(0.10721595124791, 0.13478404875209)", "(0.10921595124791, 0.13678404875209)", 
    "(0.98621595124791, 1.01378404875209)", "(0.15521595124791, 0.18278404875209)", 
    "(0.17521595124791, 0.20278404875209)", "(0.98621595124791, 1.01378404875209)", 
    "(0.0482159512479098, 0.0757840487520902)", "(0.0552159512479098, 0.0827840487520902)", 
    "(0.95121595124791, 0.97878404875209)"), `Corr between G and G_E` = c(0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.894427190999916, 0.894427190999916, 
    0.894427190999916, 0.894427190999916, 0.894427190999916, 
    0.894427190999916, 0.894427190999916, 0.894427190999916, 
    0.894427190999916, 0.894427190999916, 0.894427190999916, 
    0.894427190999916, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.894427190999916, 
    0.894427190999916, 0.894427190999916, 0.894427190999916, 
    0.894427190999916, 0.894427190999916, 0.894427190999916, 
    0.894427190999916, 0.894427190999916, 0.894427190999916, 
    0.894427190999916, 0.894427190999916), `Corr Res of y and E` = c(0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 
    0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 
    0.8, 0.8, 0.8), LL = c(0.0402159512479098, 0.0402159512479098, 
    0.0442159512479098, 0.0582159512479098, 0.0562159512479098, 
    0.98621595124791, 0.0972159512479098, 0.10021595124791, 0.98621595124791, 
    0.0362159512479098, 0.0342159512479098, 0.24421595124791, 
    0.0382159512479098, 0.0412159512479098, 0.0452159512479098, 
    0.0572159512479098, 0.0462159512479098, 0.98621595124791, 
    0.10221595124791, 0.0952159512479098, 0.98621595124791, 0.0302159512479098, 
    0.0332159512479098, 0.29821595124791, 0.0402159512479098, 
    0.0312159512479098, 0.0382159512479098, 0.0592159512479098, 
    0.0722159512479098, 0.98621595124791, 0.0882159512479098, 
    0.10421595124791, 0.98621595124791, 0.0492159512479098, 0.0452159512479098, 
    0.37221595124791, 0.0432159512479098, 0.0352159512479098, 
    0.0342159512479098, 0.10721595124791, 0.10921595124791, 0.98621595124791, 
    0.15521595124791, 0.17521595124791, 0.98621595124791, 0.0482159512479098, 
    0.0552159512479098, 0.95121595124791), UL = c(0.0677840487520902, 
    0.0677840487520902, 0.0717840487520902, 0.0857840487520902, 
    0.0837840487520902, 1.01378404875209, 0.12478404875209, 0.12778404875209, 
    1.01378404875209, 0.0637840487520902, 0.0617840487520902, 
    0.27178404875209, 0.0657840487520902, 0.0687840487520902, 
    0.0727840487520902, 0.0847840487520902, 0.0737840487520902, 
    1.01378404875209, 0.12978404875209, 0.12278404875209, 1.01378404875209, 
    0.0577840487520902, 0.0607840487520902, 0.32578404875209, 
    0.0677840487520902, 0.0587840487520902, 0.0657840487520902, 
    0.0867840487520902, 0.0997840487520902, 1.01378404875209, 
    0.11578404875209, 0.13178404875209, 1.01378404875209, 0.0767840487520902, 
    0.0727840487520902, 0.39978404875209, 0.0707840487520902, 
    0.0627840487520902, 0.0617840487520902, 0.13478404875209, 
    0.13678404875209, 1.01378404875209, 0.18278404875209, 0.20278404875209, 
    1.01378404875209, 0.0757840487520902, 0.0827840487520902, 
    0.97878404875209)), class = c("tbl_df", "tbl", "data.frame"
), row.names = c(NA, -48L))

attach(sim_results_conf_int)
library(ggplot2)
dat <- sim_results_conf_int[(`Var GxE`== 0.05),]

Power <- dat$`Mean Type 1 Err`
subcategory <- as.factor(dat$`Corr Res of y and E`)
category <- as.factor(trunc(10*dat$`Corr between G and G_E`)/10)
LL <- dat$LL
UL <- dat$UL
Model <- as.factor(dat$Model)

d <- data.frame(category, subcategory, Power, LL, UL,Model)



nFac <- 2; nDat <- 10
df <- data.frame(x = gl(nFac, nDat), 
                 y = runif(nFac * nDat))
rec <- data.frame(xmin = head(seq <- seq(0.5, nFac   .5, 1), -1), 
                  xmax = tail(seq, -1), 
                  alpha = c(0, 0.5))




C <- ggplot(data = d,  aes(x = subcategory, y = Power, color = Model))  
  scale_color_discrete(labels=c('Model 1', 'Model 2', 'Model 3')) 
  scale_x_discrete(seq_len(nFac), expand = c(0, 0))  
  geom_rect(
    data = rec,
    aes(
      xmin = xmin,
      xmax = xmax,
      alpha = alpha
    ),
    ymin = -Inf,
    ymax = Inf,
    fill = "gainsboro",
    inherit.aes = FALSE
  )  
  guides(alpha = "none") 
  geom_errorbar(data = d, aes(ymin = LL, ymax = UL), width = 0.5, position="dodge",legend.position="bottom") 
  facet_wrap( ~ category,
              labeller = as_labeller(\(x) paste0("Cor(G\u0079, G\u1D07) =  ", x)),
              strip.position = "top")  
  theme_classic() 
  theme(panel.spacing = unit(0, "lines"),
        plot.title = element_text(hjust = 0.5),
        #strip.placement = "outside",
        strip.background = element_blank(),
        strip.text.x = element_blank(),
        axis.text.x = element_text(size = 15),
        axis.text.y = element_text(size = 15),
        axis.ticks.x =element_blank(),
        legend.position=c(0.9,0.55),
        legend.title = element_blank(), 
        legend.text = element_text(size = 15),
        text = element_text(size = 15),
        legend.background = element_rect(fill = "white", color = "black"))  
  ggtitle("c. Var(GxE) = 0.05") 
  theme(plot.title = element_text(size = 15)) 
  scale_x_discrete(expand = c(0,0)) 
  xlab("Cor(\u0190\u0079, \u0190\u1D07)") 
  #force_panelsizes(cols = c(0.3, 0.3))  
  #force_panelsizes(cols = unit(2, "in")) 
  guides(shape = guide_legend(override.aes = list(size = 0.5)))

dat <- sim_results_conf_int[(`Var GxE`==0.01),]

Power <- dat$`Mean Type 1 Err`
subcategory <- as.factor(dat$`Corr Res of y and E`)
category <- as.factor(trunc(10*dat$`Corr between G and G_E`)/10)
LL <- dat$LL
UL <- dat$UL
Model <- as.factor(dat$Model)

d <- data.frame(category, subcategory, Power, LL, UL,Model)

B <- ggplot(data = d,  aes(x = subcategory, y = Power, color = Model))  
  
  scale_x_discrete(seq_len(nFac), expand = c(0, 0))  
  geom_rect(
    data = rec,
    aes(
      xmin = xmin,
      xmax = xmax,
      alpha = alpha
    ),
    ymin = -Inf,
    ymax = Inf,
    fill = "gainsboro",
    inherit.aes = FALSE
  )  
  
  geom_errorbar(data = d, aes(ymin = LL, ymax = UL), width = 0.5, position="dodge") 
  facet_wrap( ~ category,
               labeller = as_labeller(\(x) paste0("Cor(G\u0079, G\u1D07) =", x)),
               strip.position = "top")  
  theme_classic() 
  theme(panel.spacing = unit(0, "lines"),
        plot.title = element_text(hjust = 0.5),
        #strip.placement = "outside",
        strip.background = element_blank(),
        strip.text.x = element_blank(),
        axis.title.x=element_blank(),
        axis.text.y = element_text(size = 15),
        axis.text.x=element_blank(),
        axis.ticks.x =element_blank(),
        text = element_text(size = 15),
        legend.position="none")  
  ggtitle("b. Var(GxE) = 0.01") 
  theme(plot.title = element_text(size = 15)) 
  #force_panelsizes(cols = c(0.3, 0.3))  
  #force_panelsizes(cols = unit(2, "in")) 
  xlab("Cor(\u0190\u0079, \u0190\u1D07)")# 

######
library(dplyr)
library(tibble)

dat <- sim_results_conf_int[(`Var GxE`==0),]

`Type 1 Error` <- dat$`Mean Type 1 Err`
subcategory <- as.factor(dat$`Corr Res of y and E`)
category <- as.factor(trunc(10*dat$`Corr between G and G_E`)/10)
LL <- dat$LL
UL <- dat$UL
Model <- as.factor(dat$Model)

d <- data.frame(category, subcategory, `Type 1 Error`, LL, UL,Model)

A <- ggplot(data = d,  aes(x = subcategory, y = `Type 1 Error`, color = Model))  
  
  scale_x_discrete(seq_len(nFac), expand = c(0, 0))  
  geom_rect(
    data = rec,
    aes(
      xmin = xmin,
      xmax = xmax,
      alpha = alpha
    ),
    ymin = -Inf,
    ymax = Inf,
    fill = "gainsboro",
    inherit.aes = FALSE
  )  
  
  geom_errorbar(data = d, aes(ymin = LL, ymax = UL), width = 0.5, position="dodge") 
  facet_wrap( ~ category,
              labeller = as_labeller(\(x) paste0("Cor(G\u0079, G\u1D07) =", x)),
              strip.position = "top")  
  theme_classic() 
  theme(panel.spacing = unit(0, "lines"),
        plot.title = element_text(hjust = 0.5),
        strip.placement = "outside",
        strip.text = element_text(size = 15),
        axis.title.x=element_blank(),
        axis.text.y = element_text(size = 15),
        axis.text.x=element_blank(),
        axis.ticks.x =element_blank(),
        text = element_text(size = 15),
        legend.position="none")  
  ggtitle("a. Var(GxE) = 0") 
  theme(plot.title = element_text(size = 15)) 
  xlab("Cor(\u0190\u0079, \u0190\u1D07)") 
  #force_panelsizes(cols = c(0.3, 0.3))  
  #force_panelsizes(cols = unit(2, "in")) 
  geom_abline(aes(slope=0,intercept=0.05),linetype="dashed")  ylim(min, max)#  coord_fixed(ratio=4)

#$$$$$$$$$$$$$$$$$$$$
grid.newpage()
grid.draw(rbind(ggplotGrob(A),ggplotGrob(B),ggplotGrob(C), size="last"))

CodePudding user response:

You unwanted space is the result of setting the width of the error bars to .5. Hence, to get rid of that increase the width, e.g. setting width=1 will completely remove your unwanted space. And just as a suggestion, add some padding between the errobars which could be achieved by switching to position_dodge2.

Note, for the sake of minimality I reduced your code to just one plot.

library(ggplot2)

ggplot(data = d, aes(x = subcategory, y = Power, color = Model))  
  scale_color_discrete(labels = c("Model 1", "Model 2", "Model 3"))  
  scale_x_discrete(expand = c(0, 0))  
  geom_rect(
    data = rec,
    aes(
      xmin = xmin,
      xmax = xmax,
      alpha = alpha
    ),
    ymin = -Inf,
    ymax = Inf,
    fill = "gainsboro",
    inherit.aes = FALSE
  )  
  geom_errorbar(data = d, aes(ymin = LL, ymax = UL), position = position_dodge2(width = .8, padding = .2))  
  facet_wrap(~category,
    labeller = as_labeller(\(x) paste0("Cor(G\u0079, G\u1D07) =  ", x)),
    strip.position = "top"
  )  
  theme_classic()  
  theme(
    panel.spacing = unit(0, "lines"),
    plot.title = element_text(hjust = 0.5, size = 15),
    strip.background = element_blank(),
    strip.text.x = element_blank(),
    axis.text.x = element_text(size = 15),
    axis.text.y = element_text(size = 15),
    axis.ticks.x = element_blank(),
    legend.position = c(0.9, 0.55),
    legend.title = element_blank(),
    legend.text = element_text(size = 15),
    text = element_text(size = 15),
    legend.background = element_rect(fill = "white", color = "black")
  )  
  labs(
    title = "c. Var(GxE) = 0.05",
    x = "Cor(\u0190\u0079, \u0190\u1D07)"
  )  
  guides(
    shape = guide_legend(override.aes = list(size = 0.5)),
    alpha = "none"
  )

enter image description here

  • Related