【发布时间】:2019-01-11 04:22:21
【问题描述】:
这篇文章中的数据:joining all points inside a grouped point plot using ggplot 保持不变我已经添加了一列。在 Jimbou 给定解决方案的帮助下,我编写了以下代码
head(AA)
States Clusters value Comp_apply L1_25 L1_30 L1_50 x xbreaks
<chr> <chr> <dbl> <int> <int> <int> <int> <dbl> <dbl>
1 HR Cluster-1 0.0703 9 2 4 7 31 32.7
2 HR Cluster-2 0.0761 4 2 2 3 33 32.7
3 HR Cluster-3 0.0692 9 7 7 8 34 32.7
4 WB Cluster-1 0.0372 13 2 2 2 111 113.
5 WB Cluster-2 0.0762 13 2 3 6 113 113.
6 WB Cluster-3 0.0906 13 3 3 4 114 113.
现在绘图代码是
ggplot(data=data.m1)+
geom_line(aes(x = x, y = Comp_apply, group=States,color="red")
,position=position_dodge(width = 0.90))+
geom_point(aes(x = x, y = Comp_apply, group=States,color="red")
,position=position_dodge(width = 0.90))+
geom_line(aes(x = x, y = L1_25, group=States,color="green")
,position=position_dodge(width = 0.90))+
geom_point(aes(x = x, y = L1_25, group=States,color="green")
,position=position_dodge(width = 0.90))
你能帮我解决这个问题吗
【问题讨论】:
-
你有什么问题?
-
查看图例并绘制红色显示名称绿色和绿色显示红色。请参阅“Comp_apply”命令绘制它应该是红色的
-
搜索
[ggplot2] wrong colors以获取有关如何正确分配颜色的十几个问题。
标签: r ggplot2 legend line-plot