简体   繁体   English

R中的雷达图 - 雷达图中不可见的变量值和标签太长

[英]Radar diagram in R - variable values not visible in radar diagram and labels too long

I am trying to create a radar diagram in R. How to fix these 2 issues? 我正在尝试在R中创建雷达图。如何解决这两个问题?

1- Variable values are not visible 1-变量值不可见

2- Variable labels are on top of each other 2-变量标签相互重叠

And another question: 还有一个问题:

3 - How to set up a gradient colour background (from dark grey to light grey) in my graph? 3 - 如何在我的图表中设置渐变色背景(从深灰色到浅灰色)?

My data: 我的数据:

> dput(df_radar_final_new)
structure(list(`My input is well received in this clinical area.` = 58, 
    `In this clinical area, it is difficult to speak up when I perceive a problem with patient care.` = 46, 
    `Disagreements in this clinical area are resolved appropriately (i.e., not who is right but what is best for the patient).` = 69, 
    `I have the support I need from my colleagues and other staff groups to care for patients.` = 32, 
    `It is easy for staff here to ask questions when there is something that they do not understand.` = 63), row.names = 1L, class = "data.frame")

My code: 我的代码:

install.packages("fmsb")
library(fmsb)

par(mar=c(1, 2, 2, 1)) #decrease default margin
radarchart(df_radar_final_new, maxmin=FALSE)

Current output: 当前输出: 在此输入图像描述

Image 1 - After running code provided below: 图1 - 运行下面提供的代码后: 在此输入图像描述

Image 2 - What I would like to have: 图2 - 我想要的是: 在此输入图像描述

You can break text by writing \\n after words to break the text. 您可以通过在单词后面写\\n来打破文本以打破文本。

df <- structure(list(`My input is well received in this clinical area.` = 58, 
               `In this clinical area\n, it is difficult to speak up\n when I perceive a problem with patient care.` = 46, 
               `Disagreements in this\n clinical area are resolved appropriately\n (i.e., not who is right but what is best for the patient).` = 69, 
               `I have the support\n I need from my colleagues and other\n staff groups to care for patients.` = 32, 
               `It is easy for staff here\n to ask questions when there\n is something that they do\n not understand.` = 63), row.names = 1L, class = "data.frame")

df

library(fmsb)

par(mar=c(1, 2, 2, 1)) #decrease default margin
radarchart(df, maxmin=FALSE, axistype=3, pty=32, plty=1, axislabcol="red", na.itp=FALSE,
           title="(no points, axis=3, na.itp=FALSE)")

I played around a bit, you have to change the axislabcol to see your values. 我玩了一下,你必须改变axislabcol才能看到你的价值观。 Here is the documentation: https://rdrr.io/cran/fmsb/man/radarchart.html => I was not able to find a way to change the background color. 这是文档: https//rdrr.io/cran/fmsb/man/radarchart.html =>我无法找到改变背景颜色的方法。

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

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