From 9dbe61a05e63808f6b5da33a26bf918b35f527aa Mon Sep 17 00:00:00 2001 From: dellaert Date: Thu, 28 Jan 2016 00:57:24 -0800 Subject: [PATCH] Cleaned up plot --- python/gtsam_utils/__init__.py | 2 +- python/gtsam_utils/{_plot.py => plot.py} | 34 ++++++++++++------------ 2 files changed, 18 insertions(+), 18 deletions(-) rename python/gtsam_utils/{_plot.py => plot.py} (66%) diff --git a/python/gtsam_utils/__init__.py b/python/gtsam_utils/__init__.py index 0ef2dfcd3..56c55aa94 100644 --- a/python/gtsam_utils/__init__.py +++ b/python/gtsam_utils/__init__.py @@ -1 +1 @@ -from ._plot import * +from .plot import * diff --git a/python/gtsam_utils/_plot.py b/python/gtsam_utils/plot.py similarity index 66% rename from python/gtsam_utils/_plot.py rename to python/gtsam_utils/plot.py index f1603bbf5..84a388bbb 100644 --- a/python/gtsam_utils/_plot.py +++ b/python/gtsam_utils/plot.py @@ -1,11 +1,11 @@ -import numpy as _np -import matplotlib.pyplot as _plt +import numpy as np +import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D as _Axes3D def plotPoint3(fignum, point, linespec): - fig = _plt.figure(fignum) + fig = plt.figure(fignum) ax = fig.gca(projection='3d') - ax.plot([point.x()],[point.y()],[point.z()], linespec) + ax.plot([point.x()], [point.y()], [point.z()], linespec) def plot3DPoints(fignum, values, linespec, marginals=None): @@ -19,7 +19,7 @@ def plot3DPoints(fignum, values, linespec, marginals=None): # Plot points and covariance matrices for key in keys: try: - p = values.point3_at(key); + p = values.atPoint3(key); # if haveMarginals # P = marginals.marginalCovariance(key); # gtsam.plotPoint3(p, linespec, P); @@ -27,11 +27,11 @@ def plot3DPoints(fignum, values, linespec, marginals=None): plotPoint3(fignum, p, linespec); except RuntimeError: continue - #I guess it's not a Point3 + # I guess it's not a Point3 def plotPose3(fignum, pose, axisLength=0.1): # get figure object - fig = _plt.figure(fignum) + fig = plt.figure(fignum) ax = fig.gca(projection='3d') # get rotation and translation (center) @@ -39,21 +39,21 @@ def plotPose3(fignum, pose, axisLength=0.1): C = pose.translation().vector() # draw the camera axes - xAxis = C+gRp[:,0]*axisLength - L = _np.append(C[_np.newaxis], xAxis[_np.newaxis], axis=0) - ax.plot(L[:,0],L[:,1],L[:,2],'r-') + xAxis = C + gRp[:, 0] * axisLength + L = np.append(C[np.newaxis], xAxis[np.newaxis], axis=0) + ax.plot(L[:, 0], L[:, 1], L[:, 2], 'r-') - yAxis = C+gRp[:,1]*axisLength - L = _np.append(C[_np.newaxis], yAxis[_np.newaxis], axis=0) - ax.plot(L[:,0],L[:,1],L[:,2],'g-') + yAxis = C + gRp[:, 1] * axisLength + L = np.append(C[np.newaxis], yAxis[np.newaxis], axis=0) + ax.plot(L[:, 0], L[:, 1], L[:, 2], 'g-') - zAxis = C+gRp[:,2]*axisLength - L = _np.append(C[_np.newaxis], zAxis[_np.newaxis], axis=0) - ax.plot(L[:,0],L[:,1],L[:,2],'b-') + zAxis = C + gRp[:, 2] * axisLength + L = np.append(C[np.newaxis], zAxis[np.newaxis], axis=0) + ax.plot(L[:, 0], L[:, 1], L[:, 2], 'b-') # # plot the covariance # if (nargin>2) && (~isempty(P)) # pPp = P(4:6,4:6); % covariance matrix in pose coordinate frame # gPp = gRp*pPp*gRp'; % convert the covariance matrix to global coordinate frame # gtsam.covarianceEllipse3D(C,gPp); - # end \ No newline at end of file + # end