我使用ggplot创建了一个甘特图,代码如下:
compile 'org.tensorflow:tensorflow-lite:0.1'
如何格式化图表以便周末在背景上加阴影或在背景网格上描绘?
答案 0 :(得分:3)
首先,您需要获得工作日信息:
foo <- as.Date(mdfr$value)
# Generate days from first to last day
allDays <- seq(min(foo), max(foo), by = "days")
# Extract weekday
days <- data.frame(day = weekdays(allDays), date = allDays)
在周末添加geom_vline
(垂直线):
library(ggplot2)
ggplot(mdfr) +
geom_vline(data = subset(days, day %in% c("Saturday", "Sunday")),
aes(xintercept = date), color = "grey80", size = 2) +
geom_line(aes(value, name), size = 4) +
labs(title = "Project gantt chart",
x = NULL,
y = NULL) +
theme_minimal() +
theme(aspect.ratio = 0.3,
axis.text = element_text(size = 10))
答案 1 :(得分:2)
你可以尝试
struct Number
{
using NumberType = uint32_t;
operator NumberType () const
{
return this->_number;
}
NumberType _number;
};
我的想法是将library(tidyverse)
mdfr %>%
as.tibble() %>%
mutate(date=as.POSIXct(value)) %>%
ggplot(aes(date, name)) +
geom_line(size=4) +
xlab(NULL) +
ylab(NULL) +
ggtitle("Project gantt chart") +
theme_minimal() +
theme(aspect.ratio = 0.3, axis.text = element_text(size = 10)) +
scale_x_datetime(date_minor_breaks = "7 day") +
theme(panel.grid.minor.x = element_line(size=2, color = "pink"))
转换为value
格式(我在这里使用POSIXct
。但这不是必需的),然后您可以在{{1}中指定用tidyverse
轻微中断。他们每周六开始。使用更大的尺寸也将涵盖星期日。