I want to create a radar chart with ggirahExtra::ggRadar
. The problem is that I have long labels and they are clipped. I thought I could create more space between label and plot by adding margin = margin(0,0,2,0, "cm")
to element_text
in axis.text
, but its not working.
Any ideas how to increase the label space are welcome (apart from making the font smaller).
Add: As @tjebo suggests in the comments, it might be easier, or maybe the only way to make it work, to change the underlying functions in ggRadar
especially coord_radar
. Any suggestions of how to do this are welcome.
library(ggplot2)
library(ggiraphExtra)
dat <- data.frame("Item_A_Long" = 2,
"Item_B_Very_Very_Long"= 0,
"Label_Item_C" = 1,
"Item_D_Label" = 4,
"Another_very_long_label" = 3)
ggRadar(dat,
aes(
x = c(Item_A_Long,
Item_B_Very_Very_Long,
Label_Item_C,
Item_D_Label,
Another_very_long_label)
),
legend.position = "top",
colour = "white",
rescale = FALSE,
use.label = FALSE
) +
scale_y_continuous(expand = c(0,0),
limits = c(0,4)
) +
theme(panel.background = element_rect(fill = "#001957"),
# adding margin = margin(0,0,2,0, "cm") to element_text below does not help
axis.text = element_text(color = "#FFFFFF"),
panel.grid.major.y = element_blank())
Created on 2021-04-30 by the reprex package (v0.3.0)
It's a matter of clipping. The problem is also the white standard background of your drawing device. Below a hacky workaround.
turn off clipping with a modified version of
ggiraphExtra::coord_radar
as well asggiraphExtra::ggRadar
. Note I have removed a (very) few bits from the original ggRadar function, so if you need all arguments, you'd need to modify the function yourself.Turn all background elements blue
Superimpose all onto a pure blue background, I am using cowplot.
the modified functions