我有一張這樣的桌子:
df <- structure(list(Line = c("130", "131", "132", "133", "134", "135",
"136", "137", "139", "140", "141"),
Actor = c("R", "R", "R", "R", "B", "R", "B", "B", "M", "M", "M"),
Act_cat = c("ver", "SpeechRec", "ges", "ges", "gaze", "ges", "gaze", "gaze", "gaze", "gaze", "gaze"),
Activity = c("dort drüben k?nnt ihr sehen wer damals auf der sparrenburg gewohnt hat",
"schwert", "D-onset", "D-peak", "~", "D-retract", "@tum", "~", "~", "@tum", "~"),
Starttime_ms = c(48825, 48865, 49220, 50080, 50730, 50900,
51009, 51191, 51486, 51809, 52251),
Endtime_ms = c(53035, 49865, 50080, 50900, 51009, 52220, 51191, 51270, 51808, 52250,
52332),
Duration = c(4210, 1000, 860, 820, 279, 1320, 182, 79, 322, 441, 81)), class = c("grouped_df", "tbl_df", "tbl", "data.frame"), row.names = c(NA, -11L),
groups = structure(list(File = "VP_4_004", .rows = structure(list(1:11), ptype = integer(0), class = c("vctrs_list_of","vctrs_vctr", "list"))),
row.names = c(NA, -1L), class = c("tbl_df", "tbl", "data.frame"), .drop = TRUE))
我想想象一下第一個之后Activity的s在時間上如何與第一個相關,即“dort drüben k?nnt ihr sehen wer damals auf der sparrenburg gewohnt hat”。我想到的那種可視化將涉及對 each 使用 s ,它們的位置和端點將分別由它們的 和 值確定,大致如下所示:Activitygeom_segmentActivityStarttime_msEndtime_ms

如何獲得?提前致謝!
uj5u.com熱心網友回復:
這是一個快速的第一步。您可能會在此處使用geom_tile、geom_rect或geom_segment,具體取決于您要如何指定位置/大小。我認為geom_tile可能是最簡單的,但它的 x/y 是基于中心點的。
ggplot(df, aes( y = Act_cat))
geom_tile(aes(x = Starttime_ms Duration/2, width = Duration, height = 0.8, fill = Actor), color = "white")
geom_text(aes(x = Starttime_ms, label = stringr::str_wrap(Activity, 30)), hjust = 0)

轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/427637.html
