Skip to content

plotting is not succinct or consistent #23599

@zaz

Description

@zaz

Currently we plot things as so:

import sympy as sp
sp.plotting.plot3d(...)
sp.plotting.plot_parametric()

Or:

from sympy.plotting.plot import plot3d, plot_parametric
plot3d(...)
plot_parametric()

It would be nice if instead we could do:

import sympy as sp
sp.plot.3d(...)
sp.plot.parametric()

This issue has already caused us to make some (but not all) plot functions available directly under sympy (plot, plot_backends, plot_implicit, plot_parametric).

To make sympy succinct and consistent, we should make all plotting functions available directly at the top level or, better yet IMO, make all the plotting functions available under sympy.plot. This allows the user to just import sympy as sp or import sympy.plot as plot and still have a succinct way to make various kinds of plots, obviating the need to import each plot function explicitly.

The current sympy.plot() could be either retained permanently or deprecated using __call__:

>>> import sympy as sp
>>> class CallableModule(sp.__class__):
...     def __call__(self, **args):
...         sp.plotting.plot(**args)
... 
>>> sp.plotting.__class__ = CallableModule
>>> sp.plot = sp.plotting
>>> sp.plot()
>>> sp.plot.parametric()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions