I work with pulsed data, I need to add a the experimental data over square waves.
I know I can draw these in ggplot with geom_segment, but the number of them makes that an unreasonable thing to do.
I want to know if there is a way that I could add either geom_line()/geom_point() to a geom_step()?
Below is my reprex
library(tidyverse)
d <- data.frame(stage_number=gl(5, 2), Time=1:10, Voltage=runif(10, min=0, max=1000), active=rep(c("","*"),5))
df<-d %>%
split(.$stage_number) %>%
map(~add_row(., stage_number=unique(.$stage_number), Time=0, Voltage=1000, active="")) %>%
map(~add_row(., stage_number=unique(.$stage_number), Time=2100, Voltage=0, active="")) %>%
bind_rows()%>%
arrange(stage_number,Time)
df3<-df%>%
filter(active=='')
ggplot(df3, aes(x=Time, y=Voltage, col=stage_number))+
geom_step()
Main=data.frame(Time=c(0:1998, by=1),
Voltage=c( rep(c(0,1), 250), rep(c(1000,1005),250),rep(c(1,0), 250), rep(c(1000,1005), 250))
)
ggplot(Main,aes(x=Time, y=Voltage))+
geom_point()+
geom_step(aes(x=df3$Time, y=df3$Voltage, col=df3$stage_number))
Thanks for any advice that you can provide.