r - 在 coord_polar (ggplot2) 中按组分配颜色
问题描述
我需要为弧度图(ggplot2,R)中的每组实例分配不同的颜色。
类似的代码在带有 ggplot2 的条形图中对我很有效,但不适用于雷达图。
colores = c(rgb(79, 129, 189, max=255), rgb(155, 187, 89, max=255), rgb(75, 172, 198, max=255), rgb(44, 77, 117, max=255),rgb(95, 117, 48, max=255))
ggplot(data.m, aes(x = Preguntas, y = Valor, col = Comision, group = Comision), color=Comision) +
geom_polygon(fill=NA) +
coord_polar() +
theme (text = element_text(size=9.5)) +
theme ( plot.title = element_text(family="Helvetic",
size=rel(2),
vjust=2,
face="plain")) +
labs(x = "",y = "") +
theme(legend.position = "bottom") +
theme(axis.text.x = element_text(angle=0, hjust=1)) +
scale_fill_manual(values=colores) +
scale_y_continuous(limits = c(0.5,1))
我需要您为每个佣金分配不同的颜色,目前可以,但不响应“颜色”列表中的模式。
谢谢!
解决方案
从您的脚本中,您映射color = Comision
. 所以,你必须使用scale_color_manual
,而不是scale_fill_manual
。
推荐阅读
- spring - weblogic 12c上的Spring @Autowired null问题
- c# - 使用实体框架插入数据库时将导航 Id 属性自动填充到子类
- pytorch - 我正在尝试以不同的方式安装英特尔优化的 pytorch
- java - Java Spring Boot - 未经授权,邮递员
- android - 如何使用导航组件保留最后打开的片段
- javascript - MermaidJS 样式在 Chrome Mobile 中显得很奇怪
- javascript - 自动填充 HTML 选择列表
- c# - 错误 CS1061:“Button.ButtonClickedEvent”不包含“SetListener”的定义
- sql - 2 个数据库之间的简单 SELECT 查询未返回任何结果 - 继续显示“正在执行查询”
- javascript - HTML 中的“href”值可在 Android 上打开 gmail 应用程序