Skip to content

Commit 53bee86

Browse files
committed
add options to set equal aspect ratio
1 parent 4f29a45 commit 53bee86

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

‎spatialmath/base/animate.py‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -666,12 +666,14 @@ def set_xlabel(self, *args, **kwargs):
666666
def set_ylabel(self, *args, **kwargs):
667667
self.ax.set_ylabel(*args, **kwargs)
668668

669-
def plotvol2(dim, ax=None):
669+
def plotvol2(dim, ax=None, equal=False):
670670
"""
671671
Create 2D plot area
672672
673673
:param ax: axes of initializer, defaults to new subplot
674674
:type ax: AxesSubplot, optional
675+
:param equal: set aspect ratio to 1:1, default False
676+
:type equal: bool
675677
:return: initialized axes
676678
:rtype: AxesSubplot
677679
@@ -687,14 +689,18 @@ def plotvol2(dim, ax=None):
687689
if ax is None:
688690
ax = plt.subplot()
689691
ax.axis(dims)
692+
if equal:
693+
ax.set_aspect('equal')
690694
return ax
691695

692-
def plotvol3(dim, ax=None):
696+
def plotvol3(dim, ax=None, equal=False):
693697
"""
694698
Create 3D plot volume
695699
696700
:param ax: axes of initializer, defaults to new subplot
697701
:type ax: Axes3DSubplot, optional
702+
:param equal: set aspect ratio to 1:1, default False
703+
:type equal: bool
698704
:return: initialized axes
699705
:rtype: Axes3DSubplot
700706
@@ -713,6 +719,9 @@ def plotvol3(dim, ax=None):
713719
ax.set_xlim3d(dims[0], dims[1])
714720
ax.set_ylim3d(dims[2], dims[3])
715721
ax.set_zlim3d(dims[4], dims[5])
722+
723+
if equal:
724+
ax.set_aspect('equal')
716725
return ax
717726

718727
def plot_point(pos, marker='bs', text=None, ax=None, color=None, **kwargs):

0 commit comments

Comments
 (0)