tjstienstra/symmeplot

Feature request: 2D plotting

Opened this issue · 5 comments

Describe the feature you'd like
An awesome feature would be to also make projections to planes, such that you can easily make 2D plots.

To what module is your feature request related?
The projection should be made in the core. The backends will most probably also require a new Scene2D class.

as starting tip: a 2D plot can already achievable using custom axes with an orthogonal projection and a custom view location. Using this ax definition you will get the (crude) 2D plot.

_, ax = plt.subplots(subplot_kw={"projection": "3d", "proj_type": "ortho"})
ax.view_init(elev=90, azim=0, roll=90)
scene = Scene3D(N, P, scale=0.5, ax=ax)  # N = reference frame, P = Point

It does not have the nice axes as a normal 2d plot would have but it works for me, for now.

Good point. Something like this could be a nice feature to make it simpler for a user.

class Scene3D(SceneBase):
    ...
    def project_as_2d(self, frame=None) -> None:
        """Change the axis to an orhogonal projection making the view seemingly 2D.
        
        Parameters
        ----------
        frame: ReferenceFrame, optional
            Reference frame w.r.t. which the axis view is oriented aligning the users view
            with the XY plane. The default is the intertial frame of the scene.
        """
        self.ax.set_proj_type('ortho')
        self.ax.view_init(elev=90, azim=-90, roll=0)

Just reopened this issue as it would still be advantageous to also be able to plot on 2d axes. Additionally it would be nice if you could have a scene that plots multiple perspectives simultaneously.

I have look into this when implementing the feature. It's indeed the cleanest way of creating an 2d image instead of the orthogonal project used now. As I can remember, making the plot 2d would require a bit more work.

Another issue I encountered was axis limits in the animation. The limits are determined in the first frame and when the bodies move they could move out of the frame.

I have not used symmeplot for a while, so not sure how much time I can make for it.

As I can remember, making the plot 2d would require a bit more work.

Yes, it would require implementing separate artists, plot objects, and a new scene. It is basically like implementing a new backend.

Another issue I encountered was axis limits in the animation. The limits are determined in the first frame and when the bodies move they could move out of the frame.

#39 raised the issue that clipping lines on 3D axes is a bit of a nasty problem, which is partially why I've reopened this issue (2D axes are just a bit further developed).

I have not used symmeplot for a while, so not sure how much time I can make for it.

I see this feature a bit more as a long-term feature, but if you like to tackle it that would be awesome.