tulip-control / polytope

Geometric operations on polytopes of any dimension
https://pypi.org/project/polytope
Other
73 stars 19 forks source link

Plotting polytopes on same plot/ adding "_get_patch" as an import option #77

Open victoraalves opened 1 year ago

victoraalves commented 1 year ago

Hi,

I've been using polytope for a while now after using MPT for quite some time in MATLAB. Congrats on the nice work.

I've been trying to plot several polytopes in the same plot (some of these are within a Region and other from other polytopic operations) and have found the handy _get_patch inside polyope.py:

https://github.com/tulip-control/polytope/blob/17858132a92a3fba74fdbefee396957615816abb/polytope/polytope.py#L2292

But this import is not available unless chagning init.py as:

from .polytope import (
    Polytope, Region,
    is_empty, is_fulldim, is_convex, is_adjacent, is_subset,
    reduce, separate, box2poly, grid_region,
    cheby_ball, bounding_box, envelope, extreme, qhull,
    is_inside, union, mldivide, intersect, volume, projection, **__get_patch_**

From this subtle change I am able to use __getpatch to reconstruct the plot in a new figure with all polytopes I want to show in a single one: image

In the case above I am plotting a collection of convex polytopes that were inside a Region + Its respective bounding box, just for illustration purposes.

Am I overcomplicating things or should __getpatch be available for importing so it can be freely used?

Thanks.