Reputation: 11
How can I smooth out the ecg graph in an Android plot using the AdvancedLineAndPointRenderer.Formatter. Can interpolation params be used for plot or MyFadeFormatter?
Upvotes: 1
Views: 2319
Reputation: 8317
AdvancedLineAndPointRenderer does not currently support interpolation, as mentioned in the Javadoc: https://76-1424783-gh.circle-artifacts.com/0/tmp/circle-artifacts.Ra0lmjJ/javadoc/com/androidplot/xy/AdvancedLineAndPointRenderer.html
If you want you can extend AdvancedLineAndPointRenderer to add interpolation, but in general interpolation algorithms wont work well with dynamic data due to the way curves are calculated: The most recent curves would visibly mutate as the newer points are taken into account.
A second is to use beziers to get a smooth line, which is what most of the other graphing libraries use. The problem with this method is that the line that is drawn can drastically overshoot or undershoot the control points, resulting in false data. There are many posts on how to do this on StackOverflow. There's also an implementation of this in older versions of Androidplot using quadTo: https://github.com/halfhp/androidplot/blob/0.6.1/AndroidPlot-Core/src/main/java/com/androidplot/xy/BezierLineAndPointRenderer.java
Finally, and possibly the simplest approach, would be to interpolate your x/y data yourself before adding it to a series. This approach will allow you to use interpolation with any of Androidplot's existing renderers.
Upvotes: 2