import numpy as np import plotly.graph_objects as go step = 1 / 1000 t = np.arange(0, 1, step) # time vector periods = 30 # number of 'days' # function to produce base sine data # with a 7th of the base frequency overlap def data_w_weekend(t): if np.sin(periods / 7 * 2 * np.pi * t) > 0.5: value = 0.001 * np.sin(periods * 2 * np.pi * t) return max(value, 0.0) else: value = np.sin(periods * 2 * np.pi * t) return max(value, 0.0) # building the data vector my_data = [] i = 0 while i < 1000: my_data.append(data_w_weekend(i / 1000)) i += 1 # add some noise random_gain = 0.1 # factor for the noise i = 0 while i < 1000: my_data[i] += np.random.rand() * random_gain i += 1 my_data_max = np.amax(my_data) print('max value is: ' + str(my_data_max)) # normalize the data to a range up to 1.0 my_norm_data = [] i = 0 while i < 1000: my_norm_data.append(my_data[i]/my_data_max) i += 1 # plot the data trace0 = go.Scatter( x = t, y = my_norm_data, name='Logons' ) fig = go.Figure() layout = go.Layout(title="Logins over time", xaxis={'title':'time'}, yaxis={'title':'occurences'}) fig = go.Figure(data=trace0, layout=layout) fig.show()