Home > OS >  ggradar: how to increase space for long axis labels
ggradar: how to increase space for long axis labels

Time:04-09

I want to create a radar chart with ggradar package. The problem is that I have long labels and they are clipped (as shown in the figure below inside two red rectangles).

library(ggplot2)
library(tidyverse)
library(ggradar)

df <- structure(list(date = c("2022-1-31", "2022-2-28"), 
                     Item_A_Long = c(50.1, 50.2), 
                     Item_B_Very_Very_Long = c(48.4, 49), 
                     Another_Item_C_very_long_label = c(47.2, 48.6)),
                class = "data.frame", row.names = c(NA, -2L))
df

df %>% 
  mutate(across(contains('Item'), ~ (.x - 45) / 10)) %>%
  ggradar(values.radar = c('45', '50', '55'),
          legend.position = 'bottom')  
  theme(
        axis.text = element_text(hjust=0.5, vjust = 1)
        # margin = margin(0, 0, 2, 0, 'cm')
        )

Out:

enter image description here

I thought I could create more space between label and plot by adding axis.text = element_text(hjust=0.5, vjust = 1) or plot.margin = margin(0, 0, 2, 0, 'cm'), but its not working.

Any ideas how to increase the label space are welcome (apart from making the font smaller).

Reference:

enter image description here

  • Related