Hello, sorry if this a double post but my first post disappeared when I tried to add a ‘tag’ and I may have deleted it.

I am having an issue plotting a visual in a DashApp that I am building - I am new to Python and Dash - just FYI that my mistake may be trivial, however it has me stuck for a few days now.

Let me explain the setup and then I will post the code. I am taking time series data and assigning it to a dataframe (there are more than one time series tags so I moved that to a dataframe and not just a single dimension list). This dataframe gets plotted and then one of the data signals, has a Fast Fourier Transform performed on it. This is a canned function, with some additional housekeeping, that appears to currently be working - I am left with 2 arrays which are ID’d as numpy.ndarrays and both have a length of 3590 elements. The values range from X = 0-50 and the Y = 16.1-16.4. I did not chop off any sig figs or round - maybe this is an issue?

Below are three snippets: first, the FFT function - this seems to work. Second, the layout - this setup also seems to work on another graphic. Third, the callback - I set this similar to my other go.scatter using the dataframe however in this case I am trying to plot the array - in this case the size is 3590 - in some other cases it may be larger / longer and comes from the FFT function.

Finally - I took this example from a tutorial: Beginner’s Guide to Building a Multi-Page App using Dash, Plotly and Bootstrap | by Meredith Wan | Towards Data Science

Giving credit and also mentioning - I changed the code and something I need but I am not sure exactly how it is being used is the line: dff = df[df.Period == Dia_Met_name]

I know that when I remove it - it does not work.

Thanks in advance.

FFT Function

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)

Layout

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

Callback

@app.callback(

Output(‘fft_graph’, ‘figure’),

[Input(‘Dia_Met’, ‘value’)])

def update_fft(Dia_Met_name):

dff = df[df.Period == Dia_Met_name]

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