简体   繁体   English

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

[英]Radar chart is not displaying the values accurately on the axis

I am trying to create a radar chart but the axis stops at 4 when the maximum I have given is 10. Any help is much appreciated. 我正在尝试创建雷达图,但是当我给出的最大值为10时,轴停止在4位置。非常感谢您的帮助。

I have taken a subset of the dataset from a .csv file. 我从.csv文件中获取了数据集的子集。 Below is the subset 以下是子集

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))

The subset contains 10 columns and 1 row. 该子集包含10列和1行。

Code: 码:

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)

Here is the chart created: 这是创建的图表:

The highest value in the subset (datasample) is 7.581728 but the chart does not display that value. 子集中(数据样本)的最大值为7.581728,但图表未显示该值。 How do I fix this? 我该如何解决?

The radar plot you are generating has an axis that is percentages of the max data point (you can see these when you remove the caxislabels from your plot (you'll get 100%,75%,50%,25%). The values you are seeing around 3 are actually the ~7.5 values (on the 75% grid line). 您所生成的雷达图的轴是最大数据点的百分比(从图中删除caxislabels时,您会看到这些caxislabels (您将获得100%,75%,50%,25%)。您会看到3左右实际上是〜7.5的值(在75%的网格线上)。

One way to fix this so that the axis is as expected: 一种解决此问题的方法,以使轴符合预期:

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)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM