0

I have a small issue, I do not manage to space a little bit more the axis labels using annotate_figure. Is it possible? Here is my code:

 > dput(dataplotlat1[sample(nrow(dataplotlat1), 50),])
structure(list(centiles = c(60, 25, 80, 45, 65, 10, 10, 10, 40, 
25, 75, 45, 65, 20, 35, 30, 5, 75, 35, 45, 40, 55, 15, 95, 25, 
80, 60, 50, 85, 5, 15, 95, 85, 90, 65, 90, 85, 50, 50, 75, 80, 
95, 55, 35, 30, 15, 90, 20, 30, 5), Decade = c("1990-99", "2010-19", 
"1990-99", "2010-19", "1970-79", "1970-79", "2010-19", "1990-99", 
"1990-99", "1990-99", "1990-99", "1990-99", "2010-19", "1970-79", 
"1970-79", "1990-99", "1970-79", "1970-79", "2010-19", "1970-79", 
"2010-19", "1970-79", "2010-19", "1990-99", "1970-79", "2010-19", 
"2010-19", "1990-99", "2010-19", "1990-99", "1970-79", "1970-79", 
"1970-79", "1990-99", "1990-99", "2010-19", "1990-99", "1970-79", 
"2010-19", "2010-19", "1970-79", "2010-19", "2010-19", "1990-99", 
"2010-19", "1990-99", "1970-79", "1990-99", "1970-79", "2010-19"
), Julian_Day = c(80, 47, 88, 65, 87, 35, 28, 31, 67, 55, 86, 
70, 77, 49, 69, 60, 24, 92, 58, 77, 62, 83, 35, 99, 57, 84, 74, 
74, 87, 24, 44, 103, 97, 94, 82, 91, 90, 80, 69, 82, 94, 96, 
71, 64, 54, 41, 101, 50, 63, 21)), row.names = c(31L, 43L, 35L, 
47L, 13L, 2L, 40L, 21L, 27L, 24L, 34L, 28L, 51L, 4L, 7L, 25L, 
1L, 15L, 45L, 9L, 46L, 11L, 41L, 38L, 5L, 54L, 50L, 29L, 55L, 
20L, 3L, 19L, 17L, 37L, 32L, 56L, 36L, 10L, 48L, 53L, 16L, 57L, 
49L, 26L, 44L, 22L, 18L, 23L, 6L, 39L), class = "data.frame")

> dput(dataplotlat2[sample(nrow(dataplotlat2), 50),])
structure(list(centiles = c(5, 75, 20, 45, 75, 30, 55, 45, 50, 
70, 90, 30, 80, 85, 15, 20, 10, 40, 85, 5, 65, 80, 55, 95, 10, 
30, 80, 15, 65, 50, 25, 45, 95, 60, 35, 85, 60, 70, 65, 35, 40, 
90, 35, 90, 25, 55, 20, 10, 60, 5), Decade = c("2010-19", "1990-99", 
"2010-19", "1970-79", "1970-79", "1970-79", "1990-99", "1990-99", 
"2010-19", "1970-79", "2010-19", "1990-99", "1990-99", "1970-79", 
"1990-99", "1970-79", "2010-19", "1970-79", "1990-99", "1990-99", 
"2010-19", "2010-19", "1970-79", "1990-99", "1970-79", "2010-19", 
"1970-79", "2010-19", "1970-79", "1970-79", "2010-19", "2010-19", 
"2010-19", "1970-79", "1970-79", "2010-19", "2010-19", "2010-19", 
"1990-99", "2010-19", "2010-19", "1990-99", "1990-99", "1970-79", 
"1970-79", "2010-19", "1990-99", "1990-99", "1990-99", "1970-79"
), Julian_Day = c(72, 101, 83, 95, 104, 90, 95, 92, 93, 103, 
107, 87, 103, 110, 80, 87, 77, 94, 106, 60, 97, 102, 98, 112, 
80, 87, 106, 81, 102, 97, 85, 92, 112, 100, 92, 104, 96, 99, 
97, 89, 91, 109, 89, 111, 89, 94, 84, 76, 96, 74)), row.names = c(39L, 
34L, 42L, 9L, 15L, 6L, 30L, 28L, 48L, 14L, 56L, 25L, 35L, 17L, 
22L, 4L, 40L, 8L, 36L, 20L, 51L, 54L, 11L, 38L, 2L, 44L, 16L, 
41L, 13L, 10L, 43L, 47L, 57L, 12L, 7L, 55L, 50L, 52L, 32L, 45L, 
46L, 37L, 26L, 18L, 5L, 49L, 23L, 21L, 31L, 1L), class = "data.frame")

> dput(dataplotlat3[sample(nrow(dataplotlat3), 50),])
structure(list(centiles = c(80, 55, 60, 20, 25, 25, 55, 20, 40, 
20, 85, 10, 15, 5, 35, 90, 50, 95, 15, 50, 5, 45, 30, 85, 75, 
45, 70, 35, 90, 15, 75, 75, 50, 40, 65, 90, 95, 65, 45, 65, 10, 
85, 40, 60, 95, 10, 30, 5, 80, 30), Decade = c("1970-79", "1970-79", 
"1970-79", "2010-19", "2010-19", "1990-99", "2010-19", "1970-79", 
"1990-99", "1990-99", "1990-99", "1990-99", "1970-79", "2010-19", 
"1990-99", "2010-19", "2010-19", "1970-79", "2010-19", "1990-99", 
"1970-79", "1970-79", "2010-19", "2010-19", "1990-99", "1990-99", 
"1990-99", "1970-79", "1970-79", "1990-99", "2010-19", "1970-79", 
"1970-79", "1970-79", "1990-99", "1990-99", "2010-19", "2010-19", 
"2010-19", "1970-79", "1970-79", "1970-79", "2010-19", "2010-19", 
"1990-99", "2010-19", "1970-79", "1990-99", "1990-99", "1990-99"
), Julian_Day = c(110, 101, 102, 91, 93, 94, 101, 94, 99, 93, 
113, 87, 92, 83, 98, 114, 99, 122, 90, 102, 82, 99, 94, 111, 
110, 101, 108, 98, 118, 92, 106, 109, 100, 98, 107, 117, 119, 
103, 98, 104, 90, 112, 97, 102, 138, 88, 96, 75, 111, 95)), row.names = c(16L, 
11L, 12L, 42L, 43L, 24L, 49L, 4L, 27L, 23L, 36L, 21L, 3L, 39L, 
26L, 56L, 48L, 19L, 41L, 29L, 1L, 9L, 44L, 55L, 34L, 28L, 33L, 
7L, 18L, 22L, 53L, 15L, 10L, 8L, 32L, 37L, 57L, 51L, 47L, 13L, 
2L, 17L, 46L, 50L, 38L, 40L, 6L, 20L, 35L, 25L), class = "data.frame")



library(tidyr)
library(ggpubr)
library(grid) 

plot1 = ggplot(dataplotlat1,
  aes(x = centiles, y = Julian_Day, color = Decade, shape = Decade)) + 
  labs(title="South") +
  scale_y_continuous(breaks = seq(20, 110, by = 5), limits = c(20,110)) +
  geom_line() + 
  scale_color_brewer(palette = "Dark2") +
  theme_minimal()

plot2 = ggplot(dataplotlat2,
  aes(x = centiles, y = Julian_Day, color = Decade, shape = Decade)) + 
  labs(title="Middle") +
  scale_y_continuous(breaks = seq(40, 130, by = 5), limits = c(40,130)) +
  geom_line() +
  scale_color_brewer(palette = "Dark2") +
  theme_minimal()

plot3 = ggplot(dataplotlat3,
  aes(x = centiles, y = Julian_Day, color = Decade, shape = Decade)) + 
  labs(title="North") +
  scale_y_continuous(breaks = seq(60, 150, by = 5), limits = c(60,150)) +
  geom_line() +
  scale_color_brewer(palette = "Dark2") +
  theme_minimal()

output = ggarrange(plot1 + rremove("ylab") + rremove("xlab"),
              plot2 + rremove("ylab") + rremove("xlab"), 
              plot3 + rremove("ylab") + rremove("xlab"), 
              ncol=3, nrow=1,
              common.legend = TRUE, legend="right")
    
    annotate_figure(output, left = textGrob("Julian day", rot = 90, vjust = 1, gp = gpar(cex = 1.3)),
                    bottom = textGrob("Centiles", gp = gpar(cex = 1.3)))

Many thanks.

Recology
  • 165
  • 1
  • 10
  • 1
    Could you please share some reproducible data? – Quinten Jul 20 '22 at 10:45
  • 1
    As it stands, the question is hard to answer. We don't know what `plot1` is. And where do the functions `rremove()`, `textGrob()`, `annotate_figure()` and `gpar()` come from? Please provide a proper [reproducible example](https://stackoverflow.com/q/5963269/4303162). – Stibu Jul 20 '22 at 10:46
  • Of course, I have edited my post, thank you for helping, I hope it works better now – Recology Jul 20 '22 at 14:04

0 Answers0