Stop plotly from connecting gaps

Hello, so I am having trouble creating a graph that DOES NOT FILL GAPS. I have 2+years of data for this project and 6 sites. There are a lot of “NA” values in the data set and plotly automatically connects them.

I’ve tried adding connectgaps=FALSE into my code and my R doesn’t recognize it as a function.
I’ve tried replacing the “NA” values with “NaN” and still nothing changed.

Also I’ve read though and I do not understand why that graph has gaps and mine doesn’t.

Time | Q1T | Q2T | Q3T | Q4T
xxx  | NA  | NA  | NA  | NA 
xxx  | #   |  #  |  NA |#
xxx  | #   |  #  |  #  | NA   
xxx  | #   |  #  |  #  | #

Thank you

Lancer_Cistern_Graph <- plot_ly(x=Lancer$DateTime, y=Lancer$Q1T, name='Q1T', mode='line', type='scatter') %>%
    add_trace(y=Lancer$Q2T, name='Q2T', mode='line') %>%
    add_trace(y=Lancer$Q3T, name='Q3T', mode='line') %>%
    add_trace(y=Lancer$Q4T, name='Q4T', mode='line') %>%
    layout(title="Lancer Cistern T", xaxis=list(title= "Time"), yaxis=list(title= "TEMP (F)")) %>%
1 Like

Hi @McChris could it be that you’re running an old version of plotly? Could you check the version and maybe try to upgrade the package? The online doc is for the latest version, and the connectgaps parameter should be recognized.

I recently faced the same issue and it was resolved by first sorting the data by time (x axis value)
You might to give it a try.

Make sure that you use mode='lines' and not mode='line'.