0

I have some numerical results from a calculation which gives me the following plot.

enter image description here

The data is stored in a matrix sorted by the horizontal axis. Visually, I can follow each line easily and I want to fit each of them but I have no idea how to do it and what tools to use.

B200011011
  • 3,798
  • 22
  • 33
  • 1
    Welcome to [Stack Overflow.](https://stackoverflow.com/ "Stack Overflow") Please be aware this is not a code-writing or tutoring service. We can help solve specific, technical problems, not open-ended requests for code or advice. Please edit your question to show what you have tried so far, and what specific problem you need help with. See the [How To Ask a Good Question](https://stackoverflow.com/help/how-to-ask "How To Ask a Good Question") page for details on how to best help us help you. – itprorh66 Jan 21 '22 at 15:32
  • 1
    @HershJoshi A linear/polyfit regression would only work if the apparent lines that are graphed were separated into multiple datasets first, which is the point of the question – Ben Grossmann Jan 21 '22 at 15:46
  • 4
    Look into polynomial regression with RANSAC. This probably matches your question, https://stackoverflow.com/questions/55682156/iteratively-fitting-polynomial-curve. – B200011011 Jan 21 '22 at 15:47
  • @B200011011 Why would this data require RANSAC? – mikuszefski Jan 24 '22 at 06:30
  • @mikuszefski My idea was one way to solve it would be to try to iteratively apply ransac on the data points and create a mask of rejections to remove those points in next step of calculation. Doing this until all or most points were fitted. As I see no update I am not sure if it worked as expected. – B200011011 Jan 24 '22 at 10:43
  • @B200011011 okay, got it. Did not get the point that the data ( band structure, I guess) is somewhat mixed up - probably at the crossings. One might use the lowest y for all x, remove and repeat. Might already be done by a column sort. – mikuszefski Jan 24 '22 at 10:54
  • @mikuszefski Sorry about the thread, completely forgot about it. I found some kind of manual solution that sort of works: I took the first point on the y axis and then recursively matched the closest point to it and I get what I want. However, what B200011011 proposed seems interesting, so I'll take a look at it as well. Thank you ! – marecmat Jan 25 '22 at 09:28
  • Oh...find the closest is quite brute force. Isn't it that the x values repeat. so, should a sorting of the y values for every x do the trick? then take rows to plot? – mikuszefski Jan 25 '22 at 09:40
  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. – Faisal Nazik Jan 31 '22 at 13:01

0 Answers0