小编sne*_*ich的帖子

ggplot更改由x轴值指定的线条颜色

代码重现:

myDat <- data.frame(Event = rep(c("Arrival", "Departure"), 3),
                AtNode = c("StationA", "StationA", "Track", "Track", "StationB", "StationB"),
                Lane = c("Lane1", "Lane1", "Lane2", "Lane2", "Lane1", "Lane1"),
                atTime = c(10, 12, 18, 20, 34, 36),
                Type = c("Station", "Station", "Track", "Track", "Station", "Station"),
                Train = 1 )
ggplot(data =myDat, aes(x = atTime, y=factor(AtNode, levels = unique(paste(myDat[order(myDat$atTime),"AtNode"]))), group = Train, colour = Lane ))+
  geom_point(data = myDat)+
  geom_path(data = myDat[which(!grepl(pattern = "Track", myDat$Type)),])
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

现在我需要在橙色线上投射两个绿点(Y ="轨迹"),并将投影点之间的线着色为与点相同的颜色.

预期结果:(没有积分(Y ="追踪"))

在此输入图像描述

提前感谢每一个提示或技巧!

干杯

r ggplot2

3
推荐指数
1
解决办法
316
查看次数

标签 统计

ggplot2 ×1

r ×1