r - R中的雷达图 - 雷达图中不可见的变量值和标签太长
问题描述
我正在尝试在 R 中创建雷达图。如何解决这两个问题?
1-变量值不可见
2-变量标签彼此重叠
还有一个问题:
3 - 如何在我的图表中设置渐变色背景(从深灰色到浅灰色)?
我的数据:
> 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")
我的代码:
install.packages("fmsb")
library(fmsb)
par(mar=c(1, 2, 2, 1)) #decrease default margin
radarchart(df_radar_final_new, maxmin=FALSE)
解决方案
您可以通过\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)")
我玩了一下,你必须改变axislabcol
才能看到你的价值观。这是文档:https ://rdrr.io/cran/fmsb/man/radarchart.html =>我找不到改变背景颜色的方法。
推荐阅读
- r - R - 根据另一个数据框将值插入新行
- android - 为什么在集合中添加新文档时删除了在 Firestore 实时侦听器中调用的事件?
- c# - 对象在一定时间后未出现
- python - django 通过脚本进行通道身份验证
- amazon-ec2 - 如何使用mysql在aws ec2上部署python3 django2网站
- angular - Angular:将 routerLink queryParams 设置为组件属性会导致错误
- spring-cloud - Zuul 反向代理第一次请求失败
- rxjs6 - 如何处理 rxjs 帖子引发的错误
- asp.net - 刚刚更新 SSL 证书,我得到“底层连接已关闭:无法为 SSL/TLS 安全通道建立信任关系。”,
- boost - 用 yum 卸载 Boost 1.66