[英]How to vary LINE color with a variable in R graph (ggplot or similar)
[英]Line graph for one variable in r, how to color?
所以我认为使用以下内容会很简单:
df <- structure(list(time_bin = c("00", "01", "02", "03", "04", "05",
"06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16",
"17", "18", "19", "20", "21", "22", "23"), count = c(33L, 35L,
35L, 27L, 24L, 22L, 47L, 73L, 84L, 90L, 131L, 122L, 91L, 97L,
78L, 70L, 56L, 50L, 54L, 37L, 40L, 25L, 24L, 31L)), row.names = c(NA,
-24L), class = c("tbl_df", "tbl", "data.frame"))
并使用下面的代码,得到一个 plot 具有下面指定的颜色。 然而这仍然没有 plot ......
ggplot(time_bin_counts, aes(y=count, x=as.factor(time_bin), color = "mediumpurple2" )) +
geom_line() +
labs(x = "Day of the Week", y = "Injury", fill = "") +
lims(y = c(0,150)) +
theme_hc() +
theme(axis.text.x=element_text(angle = 45))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.