簡體   English   中英

ggarrange 不顯示軸標簽

[英]ggarrange not showing axis labels

我用ggplot2制作了 4 個圓形箱線圖,它們單獨看起來還不錯(盡管理想情況下,我希望 x 軸名稱更遠地位於圖之外)。

一個圓形箱線圖 但是當我使用ggarrange中的ggpubr制作多面板 plot 時,我的軸名稱部分丟失。

排列整齊的圓形箱線圖

使用以下代碼:

          ncol = 2, nrow = 2, font.label = list(size = 25)) 

我也嘗試過Gridextracowplot ,但我遇到了同樣的問題。

任何人都可以提供的任何幫助將不勝感激。

非常感謝,

年化

極坐標圖 x 軸上的文本標簽可能會出現問題。 您可能想嘗試coord_curvedpolar package 中的 coord_curvedpolar,它允許標簽圍繞 plot 彎曲,有助於防止沖突和剪裁。 此外,標簽可以使用vjust地徑向向外或向內移動

顯然,我沒有你的數據,但這是一個模型:

library(ggplot2)

df <- data.frame(Season = c("Winter\n2019", "Summer\n2019", "Autumn\n2019", 
                            "Winter\n2020", "Summer\n2020", "Autumn\n2020"),
                 Index = c(54.5, 55.5, 55, 56.4, 53.6, 55.5))

col_list <- list(c("#d14719", "#ffd175"), 
                 c("#751975", "#ffa3d1"),
                 c("#146f6f", "#75ffff"),
                 c("#751919", "#fe1818"))

p <- lapply(col_list, function(x) {
  ggplot(df, aes(factor(Season, Season), Index, fill = Index)) +
    geom_col() +
    theme_minimal(base_family = "Roboto Condensed", base_size = 12) +
    geom_vline(xintercept = 1:6, linetype = 2) +
    geom_errorbar(aes(ymin = Index - 5, ymax = Index + 5), width = 0.5) +
    geomtextpath::coord_curvedpolar() +
    scale_fill_gradient(low = x[1], high = x[2]) +
    labs(fill = "Average Total Carlson State Index") +
    guides(fill = guide_colorsteps(title.position = "top", title.hjust = 0.5)) +
    theme(legend.position = "bottom",
          legend.key.width = unit(1.5, "cm"),
          legend.key.height = unit(1.5, "mm"),
          axis.text.y = element_blank(),
          axis.title = element_blank(),
          axis.text.x = element_text(face = "bold", vjust = 0.5))
})

ggpubr::ggarrange(plotlist = p)

在此處輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM