pycapacity.visual module

Overview

This is a python module helping to visualise 2d and 3d polytopes and ellipsoids. It is based on the module matplotlib.

pycapacity.visual.plot_ellipsoid(radii=None, rotation=None, ellipsoid=None, center=None, plot=None, label=None, color=None, edge_color=None, alpha=1.0, scale=1.0)[source]

Plotting ellipsoid in 2d and 3d

Note

plot parameter can be either matplotlib.pyplot or matplotlib.axes.Axes or matplotlib.figure.Figure or mpl_toolkits.mplot3d.axes3d.Axes3D.

Examples

>>> import pycapacity.visual
>>> import matplotlib.pyplot as plt
>>> import numpy as np
>>> fig = plt.figure()
>>> pycapacity.visual.plot_ellipsoid([6,5,4],np.eye(3),plot=fig, color='blue', alpha=0.5)
>>> pycapacity.visual.plot_ellipsoid([1,2,3],np.eye(3),plot=fig, color='red', alpha=0.5)
>>> plt.show()
Parameters:
  • plot – matplotlib ax to plot on, can be either matplotlib.pyplot or matplotlib.axes.Axes or matplotlib.figure.Figure or mpl_toolkits.mplot3d.axes3d.Axes3D

  • radii – radii of the ellipsoid in each axis (optional either radii and rotation or ellipsoid must be provided)

  • rotation – rotation matrix (optional *either radii and rotation or ellipsoid must be provided*)

  • ellipsoid (Ellipsoid) – ellipsoid object - if it is provided, it will use the ellipsoid radii and rotation (optional either radii and rotation or ellipsoid must be provided)

  • center – offset of the ellipsoid from origin (optional)

  • color – face color (optional)

  • edge_color – egde collor (optional)

  • alpha – opacity (optional)

  • label – legend label (optional)

  • scale – scale the polytope with a scalar (optional)

Returns:

matplotlib ax used for plotting

Return type:

ax

pycapacity.visual.plot_polytope(polytope, plot=None, color=None, vertex_color='black', face_color=None, edge_color=None, alpha=None, label=None, center=None, scale=1.0, show_vertices=True, wireframe=False)[source]

A polytope plotting function in 2d and 3d. It plots the polytope faces and vertices from the polytope object.

Note

plot parameter can be either matplotlib.pyplot or matplotlib.axes.Axes or matplotlib.figure.Figure or mpl_toolkits.mplot3d.axes3d.Axes3D.

Parameters:
  • plot – matplotlib ax to plot on, can be either matplotlib.pyplot or matplotlib.axes.Axes or matplotlib.figure.Figure or mpl_toolkits.mplot3d.axes3d.Axes3D

  • polytope (Polytope) – polytope object it has to be provided

  • face_color – polytope face color (optional)

  • edge_color – polytope edge color (optional)

  • vertex_color – polytope vertex color (optional)

  • alpha – polytope opacity (optional)

  • label – legend label (optional)

  • center – offset the polytope (optional)

  • scale – scale the polytope with a scalar (optional)

  • show_vertices – show the vertices of the polytope (optional)

  • wireframe – show the polytope as a wireframe (optional)

  • color – polytope color - it can be either a string (one color for faces, edges and vertices) or a list of 3 values for face, edge and vertex color (optional)

pycapacity.visual.plot_polytope_faces(faces=None, polytope=None, plot=None, face_color=None, edge_color=None, alpha=None, label=None, center=None, scale=1.0, wireframe=False)[source]

Polytope faces plotting function in 2d and 3d.

Note

plot parameter can be either matplotlib.pyplot or matplotlib.axes.Axes or matplotlib.figure.Figure.

Examples

>>> import pycapacity.visual
>>> import matplotlib.pyplot as plt
>>> import numpy as np
>>> fig = plt.figure()
>>> pycapacity.visual.plot_polytope_faces([[6,5,4,3],[1,2,2,1]],plot=fig,face_color='blue')
>>> pycapacity.visual.plot_polytope_faces([[10,8,7,6],[1,2,2,1]],plot=fig,face_color='red')
>>> plt.show()
Parameters:
  • plot – matplotlib ax to plot on, can be either matplotlib.pyplot or matplotlib.axes.Axes or matplotlib.figure.Figure or mpl_toolkits.mplot3d.axes3d.Axes3D

  • faces – list of faces (optional either vertex or polytope must be provided)

  • polytope (Polytope) – polytope object - if it is provided, it will use polytope.faces (optional either vertex or polytope must be provided)

  • face_color – polytope face color (optional)

  • edge_color – polytope edge color (optional)

  • alpha – polytope opacity (optional)

  • label – legend label (optional)

  • center – offset the polytope (optional)

  • scale – scale the polytope with a scalar (optional)

  • wireframe – show the polytope as a wireframe (optional)

Returns:

matplotlib ax used for plotting

Return type:

ax

pycapacity.visual.plot_polytope_vertex(vertex=None, polytope=None, plot=None, label=None, color='black', center=None, scale=1.0)[source]

Polytope vertices plotting function in 2d and 3d

Note

plot parameter can be either matplotlib.pyplot or matplotlib.axes.Axes or matplotlib.figure.Figure or mpl_toolkits.mplot3d.axes3d.Axes3D.

Examples

>>> import pycapacity.visual
>>> import matplotlib.pyplot as plt
>>> import numpy as np
>>> fig = plt.figure()
>>> pycapacity.visual.plot_polytope_vertex(np.array([[6,5,4,3],[1,2,2,1]]),plot=fig,color='blue')
>>> pycapacity.visual.plot_polytope_vertex(np.array([[10,8,7,6],[1,2,2,1]]),plot=fig, color='red')
>>> plt.show()
Parameters:
  • plot – matplotlib ax to plot on, can be either matplotlib.pyplot or matplotlib.axes.Axes or matplotlib.figure.Figure or mpl_toolkits.mplot3d.axes3d.Axes3D

  • vertex – vertices to be plotted (optional either vertex or polytope must be provided)

  • polytope (Polytope) – polytope object - if it is provided, it will use the polytope vertices (optional either vertex or polytope must be provided)

  • color – vertex color (optional)

  • label – legend label (optional)

  • center – offset the polytope (optional)

  • scale – scale the polytope with a scalar (optional)

Returns:

matplotlib ax used for plotting

Return type:

ax