Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Radar plot peripheral labels cutoff

As you can see in this example, I'm trying to plot multiple radar charts. However, the peripheral axis labels are getting cutoff. I've tried specifying mar and oma in par, but haven't had any luck.

Can anyone else figure this out?

require(fmsb)

df <- data.frame(
  a = c(0.5, 0, 0.3),
  stopcuttingmeoff = c(1.2, 0, 0.5),
  c = c(0.25, 0, 0.1),
  d = c(0.25, 0, 0.1),
  dontcutmeoff = c(4, 0, 2))

par(mfrow=n2mfrow(4))
radarchart(df, axistype = 2, centerzero = TRUE, palcex = 0.9)
radarchart(df, axistype = 2, centerzero = TRUE, palcex = 0.9)
radarchart(df, axistype = 2, centerzero = TRUE, palcex = 0.9)
radarchart(df, axistype = 2, centerzero = TRUE, palcex = 0.9)

enter image description here

like image 278
quintinm Avatar asked Sep 04 '25 03:09

quintinm


1 Answers

A possible solution is using xpd = TRUE to prevent that the text is cut off at the margin. fsmb::radarchart internally uses text to add annotations, but unfortunately it does not allow you to pass parameters to text via ....

Therefore, you need to set the option globally:

par(xpd = TRUE, mfrow = c(2, 2), mar = c(2, 1, 2, 1))
radarchart(df, axistype = 2, centerzero = TRUE, palcex = 0.9)
radarchart(df, axistype = 2, centerzero = TRUE, palcex = 0.9)
radarchart(df, axistype = 2, centerzero = TRUE, palcex = 0.9)
radarchart(df, axistype = 2, centerzero = TRUE, palcex = 0.9)

Adjust mar to whatever values give you the desired margin on your device.

like image 154
CL. Avatar answered Sep 06 '25 10:09

CL.