Go.scatter mode scatter and lines+scatter gives different behaviour


I think that the problem is about x_axis range, in fact e

this is my code to plot my data which is dataframe of sorted datetime in the index and number of persons in nb_vald column.

data_list = []
for journey in dates:
    data =  new_data[new_data['jour'].values== journey].set_index('idnt_trnc_horr_vald')
    data_list.append(
        go.Scatter(x = data.index,
            y=list(data.nb_vald),
            name=journey,mode='lines+scatter'
                 ) )
    layout = go.Layout({'clickmode': 'event+select'},
                    xaxis={'title': 'Temps','rangemode':'normal','autorange':True, 'range' : [datetime.time(0, 0),datetime.time(23, 45)]},
                    yaxis={'title': 'nbre person ','autorange':True}
                    
    )    
fig= go.Figure(data=data_list, layout= layout) #go.Figure()
py.iplot(fig)

my data.index is varying between datetime.time(0, 0),datetime.time(23, 45), which I try to fix by fixing a xaxis range.

Thank you,

Hi @wahid_benz what is your problem here?

Hi @Emmanuelle ,
I’m actually trying to plot this kind of data, this is a sample of my data.

x1= numpy.array([datetime.time(4, 45), datetime.time(5, 15), datetime.time(5, 30),datetime.time(5, 45), datetime.time(6, 0), datetime.time(6, 15),
       datetime.time(6, 30), datetime.time(6, 45), datetime.time(7, 0),datetime.time(7, 15), datetime.time(7, 30), datetime.time(7, 45),
       datetime.time(8, 0), datetime.time(8, 15), datetime.time(8, 30),datetime.time(8, 45), datetime.time(9, 0), datetime.time(9, 15),
       datetime.time(9, 30), datetime.time(9, 45), datetime.time(10, 0),datetime.time(10, 15), datetime.time(10, 30),datetime.time(10, 45), datetime.time(11, 0), datetime.time(11, 15),datetime.time(11, 30), datetime.time(11, 45), datetime.time(12, 0),
       datetime.time(12, 15), datetime.time(12, 30),datetime.time(12, 45), datetime.time(13, 0), datetime.time(13, 15),datetime.time(13, 30), datetime.time(13, 45), datetime.time(14, 0),datetime.time(14, 15), datetime.time(14, 30),datetime.time(14, 45), datetime.time(15, 0), datetime.time(15, 15),datetime.time(15, 30), datetime.time(15, 45), datetime.time(16, 0),datetime.time(16, 15), datetime.time(16, 30),
       datetime.time(16, 45), datetime.time(17, 0), datetime.time(17, 15),datetime.time(17, 30), datetime.time(17, 45), datetime.time(18, 0),
       datetime.time(18, 15), datetime.time(18, 30),datetime.time(18, 45), datetime.time(19, 0), datetime.time(19, 15),datetime.time(19, 30), datetime.time(19, 45), datetime.time(20, 0),datetime.time(20, 15), datetime.time(20, 30),
       datetime.time(20, 45), datetime.time(21, 0), datetime.time(21, 15),datetime.time(22, 15), datetime.time(22, 45),datetime.time(23, 15), datetime.time(23, 30),datetime.time(23, 45)], dtype=object)

y1= numpy.array([ 13.,  16.,   8.,  28.,  45.,  61.,  74., 133., 191., 177., 249.,219., 249., 197.,  89.,  94.,  38.,  16.,   4.,   4.,  12.,  24.,
        15.,  34.,  19.,  23.,  93.,  30.,  40.,  30.,  54.,  41.,  27.,23.,  13.,  31.,  15.,  19.,  18.,  14.,  32.,  19.,  14.,  23.,102.,  30.,  17.,  18., 105.,  67.,  55.,  56., 106.,  50.,  25.,17.,  12.,   8.,  17.,  12.,  15.,   8.,   7.,   6.,   1.,  10.,9.,   5.,   1.,   1.,   1.])


x2 = numpy.array(
    [datetime.time(0, 15), datetime.time(4, 45), datetime.time(5, 15),datetime.time(5, 30), datetime.time(5, 45), datetime.time(6, 0),datetime.time(6, 15), datetime.time(6, 30), datetime.time(6, 45),datetime.time(7, 0), datetime.time(7, 15), datetime.time(7, 30),
       datetime.time(7, 45), datetime.time(8, 0), datetime.time(8, 15),datetime.time(8, 30), datetime.time(8, 45), datetime.time(9, 0),datetime.time(9, 15), datetime.time(9, 30), datetime.time(9, 45),datetime.time(10, 0), datetime.time(10, 15), datetime.time(10, 30),datetime.time(10, 45), datetime.time(11, 0), datetime.time(11, 15),
       datetime.time(11, 30), datetime.time(11, 45), datetime.time(12, 0),datetime.time(12, 15), datetime.time(12, 30),datetime.time(12, 45), datetime.time(13, 0), datetime.time(13, 15),datetime.time(13, 30), datetime.time(13, 45), datetime.time(14, 0),datetime.time(14, 15), datetime.time(14, 30),
       datetime.time(14, 45), datetime.time(15, 0), datetime.time(15, 15),datetime.time(15, 30), datetime.time(15, 45), datetime.time(16, 0),datetime.time(16, 15), datetime.time(16, 30),datetime.time(16, 45), datetime.time(17, 0), datetime.time(17, 15),
       datetime.time(17, 30), datetime.time(17, 45), datetime.time(18, 0),datetime.time(18, 15), datetime.time(18, 30),datetime.time(18, 45), datetime.time(19, 0), datetime.time(19, 15),datetime.time(19, 30), datetime.time(19, 45), datetime.time(20, 0),datetime.time(20, 15), datetime.time(20, 30),datetime.time(20, 45), datetime.time(21, 0), datetime.time(21, 15),
        datetime.time(21, 30), datetime.time(21, 45), datetime.time(22, 0),datetime.time(22, 15), datetime.time(22, 30),datetime.time(22, 45), datetime.time(23, 0), datetime.time(23, 15),datetime.time(23, 30)], dtype=object)

y2 = numpy.array([  1.,  16.,  15.,   7.,  27.,  27.,  86.,  39.,  92., 157., 257.,
       278., 253., 273., 217., 200.,  94.,  86.,  54.,  42.,  24.,  37.,34.,  38.,  34.,  35.,  26.,  51.,  29.,  35.,  30.,  62.,  27.,30.,  19.,  19.,  24.,  23.,  19.,  16.,  13.,  33.,  36.,  20.,
        35., 127.,  50.,  22.,  28., 103.,  84.,  43.,  41., 100.,  33.,33.,  21.,  20.,  19.,  20.,  13.,   8.,  12.,   8.,  11.,   2.,
        14.,   3.,   4.,   4.,   7.,   1.,   3.,   1.,   2.,   1.])

fig = go.Figure(data=[
    go.Scatter(
        x= x1,
        y= y1,
        mode = 'markers'
            ),
go.Scatter(
        x= x2,
        y= y2,
    mode = 'markers'
    )])
fig.show()

As you can seem my x_Axis range is varying , which I think is the main problem,
In fact I have multiple sample data like that where x_axis is a datetime.time .

each sample data (Xn,Yn) has it’s own interval and it’s own length of values but
I know that my x_axis values are varying from an interval of datetime.time(0,0) as a minimum value to a datetime.time(23,45) as maximum value with a step of 15min.

so each of my x1 , x2 …,xn is taking values in this interval , so I would like to fix the x_axis with this global interval( which i refered to range_data in the next code) and then plot any of my sample data on it.

range_data = pd.DataFrame()
range_data['range_data'] = pd.date_range("00:00", "23:45", freq="15min").time
range_data = range_data.set_index('range_data')

Thank you for help @Emmanuelle