rggplot2ggradar

ggradar: how to increase space for long axis labels


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:

Increase space for long axis labels in radar chart


Solution

  • You could increase the plot.margin and add coord_cartesian(clip = "off"). However, this distorts the dimensions of your radar chart. I played around with the plot pane to account for that. However, I'm sure there are cleverer solutions to your problem.

    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),
        plot.margin = margin(0, 5, 0, 5, 'cm')) +
      coord_cartesian(clip = "off")
    

    enter image description here