雷达图表未在轴上准确显示值

时间:2018-02-23 22:42:45

标签: r radar-chart

我正在尝试创建一个雷达图表,但是当我给出的最大值为10时,轴停在4处。非常感谢任何帮助。

我从.csv文件中获取了数据集的子集。下面是子集

datasample = structure(list(Score = 7.522, Whisker.high = 7.581728, Whisker.low = 7.462272, 
    GDP = 1.482383, Family = 1.551122, Health = 0.7925655, Freedom = 0.6260067, 
    Generosity = 0.3552805, TrustInGovernmentAndCorruption. = 0.4007701, 
    Dystopia.Residual = 2.3137), .Names = c("Score", "Whisker.high", 
    "Whisker.low", "GDP", "Family", "Health", "Freedom", "Generosity", 
    "TrustInGovernmentAndCorruption.",
    "Dystopia.Residual"), class = "data.frame", row.names = c(NA, 
    -1L))

子集包含10列和1行。

代码:

library(fmsb)

#data <- read.csv("~/Desktop/App-1/2017.csv")
#datasample <- data[2, 3:12]
datasample <- rbind(rep(10,12), rep(0,12), datasample)
radarchart(datasample, axistype = 1,
           pcol = rgb(0.2,0.5,0.5,0.9), pfcol = rgb(0.2,0.5,0.5, 0.5), plwd = 4,
           cglcol = "grey", cglty = 1, axislabcol = "grey",caxislabels = seq(0,20,1), cglwd = 0.8,
           vlcex = 0.8)

这是创建的图表:

子集(datasample)中的最高值是7.581728,但图表不显示该值。我该如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

您生成的雷达图有一个轴是最大数据点的百分比(当你从你的图中删除caxislabels时你可以看到这些(你会得到100%,75%,50%你看到的3左右的值实际上是~7.5值(在75%的网格线上)。

解决此问题的一种方法是使轴符合预期:

radarchart(datasample, axistype = 1,
           pcol = rgb(0.2,0.5,0.5,0.9), pfcol = rgb(0.2,0.5,0.5, 0.5), plwd = 4,
           cglcol = "grey", cglty = 1, axislabcol = "grey",
           caxislabels = seq(min(datasample),max(datasample),1), seg=length(seq(min(datasample),max(datasample),1))-1,
           cglwd = 0.8, vlcex = 0.8)