Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extract maxima of the peaks by a treshold from a JFreeChart XYLineChart

I want to implement a feature to a JFreeChart with a XYLineChart. So, for now I have a XYLineChart and I want to find the x-value depending the center of the peaks (see attached figure to understand what I want). So, I want to implement a threshold line (horizontal line, the blue one) which user can put where he wants, and at that specific y-value, the treshold line need to intersect the XYLine (spectrum). For me it's seems logically to start to iterate the values from that point and to see if the previous or forward points (let's say 10 points) has a lower tendency, if not, and has a higher tendency it's clear that the maxima is before the current point, and next iterate to that point and get the value of x depending of that maxima y.

Please, I need more ideas, and also if someone have time to guide me to due this thing that never done with and in JFreeChart (I think).

enter image description here

EDIT (1): This can be another solution? To extract the Y RangeValue, where the threshold line it intersect the data, and next to apply a line slope equation until the line slope equation is inversed (so there is the maxima). The LineFunction2D from JFreeChart is the way to do this?

like image 981
Apopei Andrei Ionut Avatar asked Nov 03 '22 06:11

Apopei Andrei Ionut


1 Answers

You can use a ValueMarker, illustrated here, to place a horizontal, blue line at the desired y-value. See also How do I find peaks in a dataset?.

like image 153
trashgod Avatar answered Nov 10 '22 22:11

trashgod