以下是给出时间轴值从 0-300 的堆叠条形图的代码。但我希望它是从 1 到 24。
代码:
library(ggplot2)
dataFrame <- data.frame(sr=c(1:72),
hours=c(1:24),
mode=factor(c(""),levels = c("SecureMessaging","WebLogs","IVR")),
status=factor(c("Inactive"),levels = c("Active","Inactive")))
dataFrame$mode[1:24] <- "SecureMessaging"
dataFrame$mode[25:48] <- "WebLogs"
dataFrame$mode[49:72] <- "IVR"
dataFrame$status[2] <- "Active"
dataFrame$status[7] <- "Active"
dataFrame$status[24] <- "Active"
dataFrame$status[2+24] <- "Active"
dataFrame$status[12+24] <- "Active"
dataFrame$status[15+24] <- "Active"
dataFrame$status[3+48] <- "Active"
dataFrame$status[5+48] <- "Active"
dataFrame <- na.omit(dataFrame)
plot <- ggplot(data=dataFrame, aes(x=mode, y=hours, fill=status)) + geom_bar(stat="identity")
plot <- plot+coord_flip()
plot <- plot+ggtitle("Data Analytics")
plot <- plot+xlab("Mode")
plot <- plot+ylab("Time Line")
print(plot)