0

I have a lot of spectral data in .csv format and I need to assign each spectral line to the respective sinusoid. The general idea was to load the dataset in Mathematica, ListPlot the data and then use Manipulate to plot a sinusoid over the data by dynamically adjusting the sinusoid parameters.

The code is a one-liner:

Manipulate[Show[ListPlot[data, Joined -> True, PlotRange -> {{444, 448}, Full}, AspectRatio -> 2],
ListPlot[Table[{Ampl*Sin[2 (x - Th0) Pi/180] + Freq, x}, {x, -90, 80, 5}], Joined -> True]],
{Ampl, 0.2, 1, 0.01}, {Th0, -90, 90, 5}, {Freq, 444, 448, 0.1}, ContentSize -> {400, 800}]

It works, but it's waaay to slow. The problem seems to be with the evaluation (or redrawing) of both plots, spectra and sinusoid, while only the latter has to be (re)evaluated.

Is there a way to first draw the spectral data (ListPlot) and then overlay it with dynamically updated sinusoid? Show outside the Manipulate cleary doesn't work.

P. S. As pictures say more than words:

Adjusting sinusoid parameters

0 Answers0