Dear plotly community members,
I am developing with R ; I have a dataset with xaxis as Dates, and I have two collections of points whose x values are in date1-date2 and date3-date4, with a big void between date2 and date3.
I want to avoid the line between the point (x=date2) and the point (x=date3).
Could you please help me ?
Many thanks in advance.
Jack.
Hey @jackm
I’m not sure I entirely understand, but are you looking to reveal the gap between two dates in your dataset? For example:
x <- c(2001, 2002, NA, 2003, 2004, NA, 2005, 2006, NA, 2007, 2008)
y <- c(1.1, 1.4, NA, 1.4, 1.6, NA, 1.2, 1.5, NA, 1.3, 1.6)
df <- data.frame(x, y)
plot_ly(df, x = ~x, y = ~y, name = "Gaps", type = 'scatter', mode = 'lines')
you can find more examples here: https://plot.ly/r/line-charts/#connect-data-gaps
Cheers,
Branden
Hey Branden,
Many thanks for your answer; sorry for my late reply, but I just saw it now.
It seems that I need to ‘fill’ my dataset’s gaps with (x,NA) values (I have holes in my ‘x’ axis).
I will try and I thank you very much for the idea. Much appreciated.
Best.
Jack.
Hi Branden,
Now, this works perfectly.
In addition, I’ve found a very interesting method that shows code implementing what you have suggested : https://bocoup.com/weblog/padding-time-series-with-r
Thank you again, you have dramatically helped me !
Grateful regards.
Jack.