简体   繁体   English

ggradar 返回错误:'plot.data' 包含值 > grid.max

[英]ggradar returns Error: 'plot.data' contains value(s) > grid.max

Given a sample data as follows:给定样本数据如下:

df <- structure(list(date = c("2022-1-31", "2022-2-28"), PMI = c(50.1, 
50.2), PMI.import = c(48.4, 49), PMI.export = c(47.2, 48.6)), class = "data.frame", row.names = c(NA, 
-2L))

Out:出去:

       date  PMI PMI.import PMI.export
1 2022-1-31 50.1       48.4       47.2
2 2022-2-28 50.2       49.0       48.6

I try to plot a radar plot with codes below, but none of them returns the plots I expected (need to show small difference of three variables in January and Febrary).我尝试 plot 雷达 plot 使用以下代码,但没有一个返回我预期的图(需要显示一月和二月三个变量的微小差异)。

library(scales)
library(ggiraphExtra)
library(ggradar)

df %>% 
  mutate_each(funs(rescale), -date) %>%
  ggradar()

在此处输入图像描述

ggradar(df,
        values.radar = c("40", "50", "70"),
        grid.min=40, grid.mid=50, grid.max=60
)

在此处输入图像描述

and ggradar(df) returns: Error: 'plot.data' contains value(s) > grid.maxggradar(df)返回: Error: 'plot.data' contains value(s) > grid.max

Does someone could help?有人可以帮忙吗? I hope to set y limit ie., between 40~70 or 40~60 to show the small changes of data between two months if it's possible.我希望设置 y 限制,即在 40~70 或 40~60 之间,以显示两个月之间数据的微小变化(如果可能的话)。

Reference:参考:

https://github.com/ricardo-bion/ggradar/issues/7 https://github.com/ricardo-bion/ggradar/issues/7

I think you need to scale your data so that, say, the values 45 - 55 map to the range 0 - 1. Then just label the plot appropriately:我认为你需要缩放你的数据,例如,值 45 - 55 map 到范围 0 - 1。然后只是 label plot 适当:

df %>% 
  mutate(across(contains('PMI'), ~ (.x - 45) / 10)) %>%
  ggradar(values.radar = c('45', '50', '55'))

在此处输入图像描述

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

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