【发布时间】:2015-12-26 16:48:30
【问题描述】:
这个问题是以前回答的问题中的一个新问题:Plot mean of data within same ggplot
正如您在下面的 .jpg 图片中看到的那样——红线 geom_path 被挤在一起,使这条线更难解释。有没有办法稍微“弯曲”曲线以减少重叠/聚束?围绕点进行某种平滑或弯曲以使线条不重叠?
这是我的语法:
orbit.plot <- ggplot(orbit.data, aes(x=OpM, y=INVT, colour=Subj, label=Year)) +
geom_point(size=7, shape=20) +
geom_path(size=1.5) +
ggtitle("Title Orbits") +
geom_text(data=subset(orbit.data,Year==2006 | Year==2014), aes(label=Year, vjust=1, hjust=1)) +
theme(panel.background = element_rect(fill = 'white', colour = 'red'),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank()) +
geom_vline(xintercept=0, size=1) +
geom_hline(yintercept=7, size=1) +
scale_y_continuous(limits = c(7, 15), breaks=seq(7,15,1/2))
这是数据集的输出:
structure(list(Year = c(2006L, 2006L, 2007L, 2007L, 2008L, 2008L,
2009L, 2009L, 2010L, 2010L, 2011L, 2011L, 2012L, 2012L, 2013L,
2013L, 2014L, 2014L), Subj = structure(c(2L, 1L, 2L, 1L, 2L,
1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L), .Label = c("TMC",
"HMC"), class = "factor"), OPM = c(0.088, 0.09, 0.095, 0.078,
0.085, 0.08, -0.023, 0.019, 0.009, 0.043, 0.025, 0.065, 0.0199,
0.029, 0.06, 0.055, 0.088, 0.065), Invt = c(14.5, 10.3, 13.8,
10, 13.3, 9.5, 12.3, 8, 13.5, 8, 14.3, 10, 13.2, 8.5, 13.8, 9.5,
13.8, 9.75)), .Names = c("Year", "Subj", "OpM", "INVT"
), class = "data.frame", row.names = c(NA, -18L))
谢谢。
编辑:更新:本质上,这个图的原因是随着时间的推移显示 x/y 变量“运动”。在 X 轴上——我正在绘制一个比率(在这种情况下为操作裕度)。在 Y 轴上——我正在显示一个周期测量值(在这种情况下是库存周转。)曲线的“弯曲”肯定会“弯曲”数据本身——但是我使用的是 X/Y 测量值,数据被理解为两 (2) 位小数 - 因此数据的“轻微”弯曲不会污染数据试图描绘的“本质”。
【问题讨论】:
-
this 的帖子有用吗?
-
有时我认为人们对帖子投反对票仅仅是因为他们对无法解决问题感到恼火。
-
你希望你的情节传达什么信息?
-
Richo64:感谢您提供的链接和建议——在我仔细检查之后,这些信息可能会有所帮助——再次感谢。
-
样条线有帮助吗?