Hey, sorry if this is not the right section to post in, the topic is a bit ambiguous. I've generated a set of coordinate points for the orbit of Mercury (3d cartesian) and now I want to fit an ellipse through it so I can get an accurate estimate of the location of the perihelion. I am using python (as an excuse to learn the language) and I find this task to be a lot more complicated than I've initially hoped: So far I only managed to plot the 2d projection of the ellipse onto the xy plane, using least squares fitting (alternatively I can do the same with the other two planes) but I am struggling to come up with a way to take it to the third dimension. I thought maybe I can fit an ellipsoid, or fit a plane through Mercury's ecliptic and somehow reduce it back to a 2d problem, but quite frankly after a lot of googling and browsing of papers I came to the conclusion that I just don't know how to do either of these things. I need some advice. Could someone please give me a few pointers? Thank you.