【发布时间】:2020-03-31 18:10:44
【问题描述】:
我正在制作一个闪亮的应用程序,我正在使用geom_line(aes(x= x, y =y, group = g, colour = g), size=2, na.rm=T),然后是geom_point(aes(x= x, y = x, group = g, colour = g), size=5, na.rm=T, shape=16),我有一组线(此处为绿色)在点后面但在另一组线上方(此处粉红色)。
代码:
library(ggplot2)
ggplot(data=df2, aes(x=DateRelCases, y = CasesCumMod)) +
geom_line(aes(x= DateRelCases, y =CasesCumMod, group = Country, colour = Country), size=2, na.rm=T) +
geom_point(aes(x= DateRelCases, y =CasesCumMod, group = Country, colour = Country),size=5, na.rm=T, shape=16)
数据:
df2 <- data.frame(Country = structure(c(rep(2L, 30), rep(3L, 30), rep(1L, 30)), .Label = c("ES", "FR", "IT"), class = "factor"),
DateRelCases = structure(rep(30:1,3)),
CasesCumMod = c(40174, 37575, 32964, 29155, 25233, 22302,
19856, 16018, 14459, 12612, 10995, 9134, 7730, 6633, 5423,
4499, 3661, 2876, 2281, 1784, 1412, 1126, 716, 613, 423,
285, 212, 178, 130, 100, 97689, 92472, 86498, 80539, 74386,
69176, 63927, 59138, 53578, 47021, 41035, 35713, 31506, 27980,
23980, 17750, 17660, 15113, 12462, 10149, 9172, 7375, 5883,
4636, 3858, 3089, 2502, 1835, 1689, 1128, 78797, 72248, 64059,
56188, 47610, 39673, 33089, 28572, 24926, 19980, 17147, 13716,
11178, 9191, 7753, 5753, 4231, 3004, 2140, 1639, 1204, 589,
430, 374, 261, 200, 151, 114, 83, 66))
【问题讨论】:
-
(1) 这是在闪亮的应用程序中特有的,还是在控制台上也这样做? (2) 没有可复制的东西,我们怎么能提供帮助?
-
大部分代码似乎与您在
ggplot2中的分层问题无关。您是否尝试过我回答中的方法? -
查看我建议的编辑。 那 更接近于 MWE,因为我们不需要(或关心)知道您是如何获得数据的。但是,本着 MWE 的精神,如果没有
ggdark,你能复制吗?对于安装了ggplot2的人来说,这很简单,只是尝试一下,但是突然出现错误(如could not find function "dark_theme_dark"),你开始输了人们的兴趣。 -
非常感谢,我不知道
dput,以后会用到。我删除了所有不必要的代码 -
也许讨论晚了,但有一些很好的参考资料可以让问题足够大(并且很好)以鼓励轻松阅读和“尝试”寻找潜在答案的方式:@ 987654322@、minimal reproducible example 和 stackoverflow.com/tags/r/info。希望我的回答解决了你的问题!您有几个问题(和答案),所以我没有像对待新 SO 用户那样立即跳到那个参考列表。