Missing line in mode = 'lines'


#1

Hi,

I am in python3 (jupyter on mac os) and I just got this weird issue, in my go.scatter plot – a piece of the line is missing

any idea on what’s going on?

Thanks for your help


#2

connectgaps=True connects last with first data unfortunately


#3

Paste your code and data, please. We can help you only seeing what’s wrong in your code, and data.


#4

Sure,

here is how I am building the trace:

full_trace = []

full_trace.append(
    go.Scatter(
    x = my_df.temp_var,
    y = my_df.cases,
    mode = 'lines+markers',
#     connectgaps=True, ## not working properly! -- connecting last w/ first 
    name = 'VENEZUELA'
    )
)

#5

and this is the subset of the dataset close to that gap

temp_var,cases
2017-01-08,6043
2017-01-15,8087
2016-12-18,4854
2016-12-25,3757
2017-01-01,3081

#6

Did you sort the dataframe by date?


#7

thanks – sorting the df fixed the issue

(however, I don’t see why the plot should depend on the sorting of the df)


#8

@grgr If you remember a math function, f:[a, b]-->R, is defined on an interval that is an ordered set, and to get its graph you are plotting the line passing through 2d points of coordinates (x, f(x)), with x in [a,b]. Python and other programming languages works with a discretized function, i.e. you evaluate that function at some arguments
a=x_0<x_1<....< x_n=b.
Your line is defined on a time interval, that’s why you should sort the dataframe by date.