Issue plotting FFT from numpy.ndarray

I am having an issue when I try to generate a FFT of a data set and then plot this in a Dashapp using go.scatter() function. I am new to programming - please be gentle.

  1. Here is my function - it takes a dataframe that I already plot, performs an FFT and some housekeeping on the data and then provides a sample rate for the x axis. The two data arrays X and Y end up being 3590 in size and their type is numpy.ndarray. The function is pasted after the full comments for reference

  2. Below, I attached the layout - I use the exact same layout (with different names) to plot the time series data that is the base data set for the FFT. (please note that in this snippet - I included the graph that works (this is the top graph in the code) and the code for the graph that does not work - fft_graph. Thanks.

  3. Below that, I include the plot code - I try to use go.scatter and drop the array x=[1:] in order to plot the 3590 point array. When the graphic publishes, there is not data and only data point at the origin.

The x data ranges from 0-50 and the Y data is a frequency of roughly 16.1-16.4… There are many figs in the data - hardly any are significant, I could truncate the number quite a bit if this is the issue. Please note (I have tried other syntax of array calling, such as x=[1:10] or x=[1:3590] or x=[1] - all attempts fail to provide a visual - all attempts compile and load with no errors.

Thanks in advance…

Function Code (FFT)

dat=df0.values
N=dat.size-1
sample_rate=N/(df0.index.max()-df0.index.min()).total_seconds() # sample rate in points per seconds
duration=N/sample_rate
y=rfft(dat)
x=rfftfreq(2*N,1/sample_rate)
y2=np.abs(y)
print(len(x))
print(len(y2))
print(min(x), max(x))
print(min(y2), max(y2))
#print(x)
#print(y2)
print(type(x))
print(type(y2))

app.layout = dbc.Container([
dbc.Row([
        dbc.Col(html.H5(children='Focus Measurement - A Window in Time', className="text-center"),
                className="mt-4")
    ]),

    dcc.Graph(id='graph_by_period',
              hoverData={'points': [{'x': '11-May'}]}),


    dbc.Row([
        dbc.Col(html.H5(children='Discrete Fast Fourier Transform', className="text-center"),
                className="mt-4")
    ]),

    dcc.Graph(id='fft_graph')
        ]),
])

@app.callback(
    Output('fft_graph', 'figure'),
    [Input('Dia_Met', 'value')])
def update_fft(Dia_Met):
    #dfft = pd.DataFrame({'x': x, 'y': y})

    data = [go.Scatter(x=x[1:], y=y2[1:],
                       mode='lines', name='FFT')
    ]
    layout = go.Layout(
        yaxis={'title':"Freq"},
        xaxis={'title':"X axis"}

    )
    return {'data': data, 'layout': layout}