Davide-sd / sympy-plot-backends

An improved plotting module for SymPy
BSD 3-Clause "New" or "Revised" License
42 stars 9 forks source link

New `plot3d_list` function? #9

Closed James-G-Hill closed 1 year ago

James-G-Hill commented 1 year ago

I created a sphere with plot3d_spherical then wanted to use the output in plot_geometry. It seemed however that a plot3d_list function where one can pass in x, y, z as separate lists would be an easier solution (I could easily reuse my sympy Point object coordinates too.)

Davide-sd commented 1 year ago

Thanks for the suggestion. I'll give it a try in the next few days! Hopefully I'll be able to create a new release by the end of the week.

Davide-sd commented 1 year ago

@James-G-Hill I've just released the new version with plot3d_list. Give it a try and eventually let me know if this issue can be closed.

James-G-Hill commented 1 year ago

@Davide-sd Great! Tried it and it works for me. Super fast turn around too.

James-G-Hill commented 1 year ago

The latest version seems to have a problem with plot_geometry now when using 3d geometrical entities. I tried this which was definitely working yesterday prior to upgrading version:

plot_geometry((Point3D(0, 0, 0), '0'))

It returns with:

ValueError                                Traceback (most recent call last)
<ipython-input-42-c13de1de6110> in <module>
      1 plot_geometry(
----> 2     (Point(0, 0, 0), '0')
      3 )

~/.local/share/virtualenvs/general/lib/python3.7/site-packages/spb/functions.py in plot_geometry(*args, **kwargs)
   3532 
   3533     Backend = kwargs.pop("backend", THREE_D_B if any_3D else TWO_D_B)
-> 3534     return _instantiate_backend(Backend, *series, **kwargs)
   3535 
   3536 

~/.local/share/virtualenvs/general/lib/python3.7/site-packages/spb/utils.py in _instantiate_backend(Backend, *series, **kwargs)
    404 
    405     if kwargs.get("show", True):
--> 406         p.show()
    407     return p
    408 

~/.local/share/virtualenvs/general/lib/python3.7/site-packages/spb/backends/matplotlib.py in show(self, **kwargs)
   1165             Keyword arguments to be passed to plt.show().
   1166         """
-> 1167         self.process_series()
   1168         if _show:
   1169             self._fig.tight_layout()

~/.local/share/virtualenvs/general/lib/python3.7/site-packages/spb/backends/matplotlib.py in process_series(self)
   1154         # behaviour is specific to Matplotlib
   1155         self._create_figure()
-> 1156         self._process_series(self.series)
   1157 
   1158     def show(self, **kwargs):

~/.local/share/virtualenvs/general/lib/python3.7/site-packages/spb/backends/matplotlib.py in _process_series(self, series)
    428                     x, y, z, param = s.get_data()
    429                 else:
--> 430                     x, y, z = s.get_data()
    431                     param = np.ones_like(x)
    432                 lkw = dict()

ValueError: too many values to unpack (expected 3)

The example plot with 3d geometric entities also no longer appears in the documentation on this page: https://sympy-plot-backends.readthedocs.io/en/latest/modules/functions.html#spb.functions.plot_geometry

Davide-sd commented 1 year ago

Nice catch! plot_geometry is definitely the least tested function of the module: unfortunately, I don't really use the geometry module that much. If you find any other bugs, please open issues :)

Anyway, I've just applied a fix and released a new version.

James-G-Hill commented 1 year ago

Cool, I will check. plot_geometry is my favorite function. I wrote a similar set of ad hoc functions for a bunch of notebooks I was working from earlier in the summer, but that was before I found this package. I will go back and rework to use yours at some point when I have time.