Skip to content

Commit d5a21af

Browse files
committed
reinstate plot_pdf
graphics tidyup
1 parent bb96f41 commit d5a21af

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

roboticstoolbox/mobile/ParticleFilter.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ def run(self, T=10, x0=None):
285285

286286
# display the initial particles
287287
if self.robot._animation is not None:
288-
self.h, = plt.plot(self.x[:, 0], self.x[:, 1], 'go', zorder=0, markersize=3, markeredgecolor='none', alpha=0.3)
288+
self.h, = plt.plot(self.x[:, 0], self.x[:, 1], 'go', zorder=0, markersize=3, markeredgecolor='none', alpha=0.3, label='particle')
289289
# set(self.h, 'Tag', 'particles')
290290

291291
# self.robot.plot()
@@ -346,24 +346,24 @@ def step(self):
346346
)
347347
self._history.append(hist)
348348

349-
# def plot_pdf(self):
350-
# #ParticleFilter.plot_pdf Plot particles as a PDF
351-
# #
352-
# # PF.plot_pdf() plots a sparse PDF as a series of vertical line
353-
# # segments of height equal to particle weight.
354-
# clf
355-
# hold on
356-
# for p = 1:self.nparticles
357-
# x = self.x(p,:)
358-
# plot3([x[0] x[0]], [x[1] x[1]], [0 self.weight(p)], 'r')
359-
# plot3([x[0] x[0]], [x[1] x[1]], [0 self.weight(p)], 'k.', 'MarkerSize', 12)
360-
361-
# end
362-
# grid on
363-
# xyzlabel
364-
# zlabel('particle weight')
365-
# view[29,59]
366-
# rotate3d on
349+
def plot_pdf(self):
350+
#ParticleFilter.plot_pdf Plot particles as a PDF
351+
#
352+
# PF.plot_pdf() plots a sparse PDF as a series of vertical line
353+
# segments of height equal to particle weight.
354+
ax = base.plotvol3()
355+
for (x, y, t), weight in zip(self.x, self.weight):
356+
# ax.plot([x, x], [y, y], [0, weight], 'r')
357+
ax.plot([x, x], [y, y], [0, weight], 'skyblue', linewidth=3)
358+
ax.plot(x, y, weight, 'k.', markersize=6)
359+
360+
361+
plt.grid(True)
362+
plt.xlabel('X')
363+
plt.ylabel('Y')
364+
plt.xlim()
365+
ax.set_zlabel('particle weight')
366+
ax.view_init(29, 59)
367367

368368

369369
# def plot_xy(self, varargin):

0 commit comments

Comments
 (0)