2
$\begingroup$

I have a data file.

I must plot this using ListLogLinearPlot and identify the trend (or the mean). Below is my code for Importing the data file and plotting it.

d = Import[NotebookDirectory[] <> "TEST1.dat"];
ListLogLinearPlot[d, Joined -> True]

enter image description here

I have followed the examples in the Documentation and an answer, here, given by @Bob Hanlon to produce my desired graph.

  • However, I failed miserably.

The codes for the two methods with the unwanted graphs are shown below.

Method-1

filtered1 = MeanFilter[d, 50];
filtered2 = MedianFilter[d, 50];
filtered3 = MaxFilter[d, 10];

ListLogLinearPlot[{d, filtered1, filtered2, filtered3}]

enter image description here

Method-2

{max, mean, min} = # /@ d & /@ {Max, Mean, Min};

ListLogLinearPlot[{d, max, mean, min}, PlotRange -> Full]

enter image description here


I need a plot that should, more or less, look like this:

enter image description here

How do I achieve my desired result? Any help would be appreciated. Thank you.

$\endgroup$

1 Answer 1

5
$\begingroup$

You are not using the filters correctly. You should apply them only to the $y$ values, but when you do MeanFilter[d, 50], the filter is applied also to the $x$ values.

An elegant way is to use TimeSeries, which *Filter functions recognize and are correctly applied only to the $y$ values.

ts = TimeSeries[d];
filtered1 = MeanFilter[ts, 50];
filtered2 = MedianFilter[ts, 50];
filtered3 = MaxFilter[ts, 10];

ListLogLinearPlot[{ts, filtered1, filtered2, filtered3}, Joined -> True]

enter image description here

$\endgroup$
1
  • $\begingroup$ Thank yo for pointing out my mistake. :) $\endgroup$
    – user444
    Feb 13 at 16:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.