本文介绍了R ggplot甘特图中没有显示条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 结构(list(JobName = structure(c(1L,1L,1L) ,2L,2L,2L),.Label =( ATLAS_Admin_DeployClientDatabase, ATLAS_Admin_ParseMasterCubeDatabase,ATLAS_Admin_xBackup_DeleteOldTable BDC_DatabaseMaintenanceJob_ALL_DATABASES,collection_set_1_noncached_collect_and_upload, CoreX_SAP_B23_dreprecated,CoreXBI_ETL_1014_01Stage, CoreXBI_ETL_1014_02DWH_Cube, CoreXBI_ETL_1114_02DWH_Cube, CoreXBI_ETL_1294_B23,CoreXBI_ETL_AutoTest ,DELM DEV日志,Delphi DEV Load,Delphi DEV月度日志,mdw_purge_data_ [Z_MAS_MDW],QA_CoreXBI_ETL_1010,QA_CoreXBI_ETL_1294,Shrink_the_Logs,SSIS服务器维护作业,syspolicy_purge_history,sysutility_get_cache_tables_data_into_aggregate_tables_daily sysutility_get_cache_tables_data_into_aggregate_tables_hourly,sysutility_get_views_data_into_cache_tables,Z_MAS_ADMIN_ALRS,Z_MAS_ADMIN_Backup_AMOTables,Z_MAS_ADMIN_Check_Cube_Space,Z_MAS_ADMIN_Check_Disk_S (1478788776,1479292645,1479307979,1479292220,1479307916,479314398),等级=因子),运行日期时间,Z_MAS_ADMIN_Extract_Job_History,Z_MAS_ADMIN_Monitoring,Z_MAS_MaintenancePlan.weekly_bak_clean,Z_MICE_System_Database_Backup_weekly c(POSIXct,POSIXt),tzone =),StartWeekday = tructure(c(5L,7L,7L,7L,7L,7L),.Label = c(Friday,Monday星期二,星期二,星期二,星期三),class =factor),tartTime = structure(c(-2209108824,-2209123355,-2209108021,-2209123780,2209108084,-2209101602), class = c(POSIXct,POSIXt),tzone =),ndRunDateTime = structure(c(1478790159,1479294190,1479309546,1479292284,479307977,1479314459),class = c(POSIXct,POSIXt) (周五,星期一,星期六,星期天,星期四,星期一,星期六, Tuesday,Wednesday),class = factor),EndTime = structure(c(-2209107441,-2209121810,-2209106454,2209123716,-22091080 ),.Names = c(JobName,RunDateTime,StartWeekday,StartTime,EndRunDateTime, EndWeekday,EndTime),row.names = c(NA,L),class =data.frame) 现在我使用以下脚本创建甘特图,其中应显示时间线中不同作业的持续时间。 数据集[变量]< - lapply (数据集[变量],as.POSIXct,format =%Y-%m-%dT%H:%M:%S) df mdfr library(ggplot2) ggplot(mdfr,aes(x = value,y = name,color = variable)) geom_line(size = 6) xlab(NULL) ylab(NULL) 我的问题是,我在y轴上得到一个带有JobNames的图表和日期时间在x轴上,但没有值或酒吧。 任何想法是什么? 编辑:下一个问题是现在,它连接了第一个开始时间和最后一个结束时间... 解决方案你并没有将情节添加到情节中。尝试: pre $ g $ p $ ggplot(mdfr,aes(x = value,y = name,color = variable))+ geom_line(size = 6)+ xlab(NULL)+ ylab(NULL) I have the following dataset as source:structure(list(JobName = structure(c(1L, 1L, 1L, 2L, 2L, 2L), .Label = ("ATLAS_Admin_DeployClientDatabase", "ATLAS_Admin_ParseMasterCubeDatabase", ATLAS_Admin_xBackup_DeleteOldTable", "BDC_DatabaseMaintenanceJob_ALL_DATABASES", collection_set_1_noncached_collect_and_upload", "CoreX_SAP_B23_dreprecated", CoreXBI_ETL_1014_01Stage", "CoreXBI_ETL_1014_02DWH_Cube", "CoreXBI_ETL_1114_02DWH_Cube", "CoreXBI_ETL_1294_B23", CoreXBI_ETL_AutoTest", "Cycle_Log", "Delphi DEV Load", "Delphi DEV Monthly", mdw_purge_data_[Z_MAS_MDW]", "QA_CoreXBI_ETL_1010", "QA_CoreXBI_ETL_1294", Shrink_the_Logs", "SSIS Server Maintenance Job", "syspolicy_purge_history", sysutility_get_cache_tables_data_into_aggregate_tables_daily", "sysutility_get_cache_tables_data_into_aggregate_tables_hourly", "sysutility_get_views_data_into_cache_tables", "Z_MAS_ADMIN_ALRS", "Z_MAS_ADMIN_Backup_AMOTables", "Z_MAS_ADMIN_Check_Cube_Space", "Z_MAS_ADMIN_Check_Disk_Space", "Z_MAS_ADMIN_Extract_Job_History", "Z_MAS_ADMIN_Monitoring", "Z_MAS_MaintenancePlan.weekly_bak_clean", "Z_MICE_System_Database_Backup_weekly"), class = "factor"), RunDateTime = tructure(c(1478788776, 1479292645, 1479307979, 1479292220, 1479307916, 479314398), class = c("POSIXct", "POSIXt"), tzone = ""), StartWeekday = tructure(c(5L, 7L, 7L, 7L, 7L, 7L), .Label = c("Friday", "Monday", Saturday", "Sunday", "Thursday", "Tuesday", "Wednesday"), class = "factor"), tartTime = structure(c(-2209108824, -2209123355, -2209108021, -2209123780, 2209108084, -2209101602), class = c("POSIXct", "POSIXt"), tzone = ""), ndRunDateTime = structure(c(1478790159, 1479294190, 1479309546, 1479292284, 479307977, 1479314459), class = c("POSIXct", "POSIXt"), tzone = ""), ndWeekday = structure(c(5L, 7L, 7L, 7L, 7L, 7L), .Label = c("Friday", Monday", "Saturday", "Sunday", "Thursday", "Tuesday", "Wednesday"), class = factor"), EndTime = structure(c(-2209107441, -2209121810, -2209106454, 2209123716, -2209108023, -2209101541), class = c("POSIXct", "POSIXt"), tzone "")), .Names = c("JobName", "RunDateTime", "StartWeekday", StartTime", "EndRunDateTime", "EndWeekday", "EndTime"), row.names = c(NA, L), class = "data.frame")Now I use the following script to create a Gantt chart out of data that should show me the durations of the different jobs in the timeline.library(reshape2)vars <- c("RunDateTime", "EndRunDateTime", "StartTime", "EndTime")dataset[vars] <- lapply(dataset[vars], as.POSIXct, format = "%Y-%m-%dT%H:%M:%S")df <- with(dataset, data.frame(name = JobName, start = RunDateTime, end = EndRunDateTime))mdfr <- melt(df, measure.vars = c("start", "end"))library(ggplot2)ggplot(mdfr, aes( x = value, y = name, color = variable))geom_line(size = 6)xlab(NULL)ylab(NULL)My problem is, that I get a chart with JobNames on the y-axis and DateTimes on the x-axis, but no values or bars in it.Any idea what it's about?EDIT: Next problem is now, that it connects the very first start time with the very last end time... 解决方案 You're not adding the geoms to the plot. Try:ggplot(mdfr, aes( x = value, y = name, color = variable)) + geom_line(size = 6) + xlab(NULL) + ylab(NULL) 这篇关于R ggplot甘特图中没有显示条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 07-02 09:01