Skip to content

Commit 4e40dfd

Browse files
committed
Fix matplotlib sliders
1 parent 8af819a commit 4e40dfd

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

roboticstoolbox/backends/PyPlot/PyPlot.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -572,11 +572,21 @@ def update(val, text, robot): # pragma: no cover
572572

573573
if robot.isrevolute(j):
574574
slider = Slider(
575-
ax, "q" + str(j), qlim[0, j], qlim[1, j], np.degrees(q[j]), "% .1f°"
575+
ax=ax,
576+
label="q" + str(j),
577+
valmin=qlim[0, j],
578+
valmax=qlim[1, j],
579+
valinit=np.degrees(q[j]),
580+
valfmt="% .1f°",
576581
)
577582
else:
578583
slider = Slider(
579-
ax, "q" + str(j), qlim[0, j], qlim[1, j], robot.q[j], "% .1f"
584+
ax=ax,
585+
label="q" + str(j),
586+
valmin=qlim[0, j],
587+
valmax=qlim[1, j],
588+
valinit=robot.q[j],
589+
valfmt="% .1f",
580590
)
581591

582592
slider.on_changed(lambda x: update(x, text, robot))

roboticstoolbox/backends/PyPlot/PyPlot2.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -344,16 +344,21 @@ def update(val, text, robot): # pragma: no cover
344344

345345
if robot.isrevolute(j):
346346
slider = Slider(
347-
self.axjoint[j],
348-
"q" + str(j),
349-
qlim[0, j],
350-
qlim[1, j],
351-
np.degrees(q[j]),
352-
"% .1f°",
347+
ax=self.axjoint[j],
348+
label="q" + str(j),
349+
valmin=qlim[0, j],
350+
valmax=qlim[1, j],
351+
valinit=np.degrees(q[j]),
352+
valfmt="% .1f°",
353353
)
354354
else:
355355
slider = Slider(
356-
self.axjoint[j], "q" + str(j), qlim[0, j], qlim[1, j], q[j], "% .1f"
356+
ax=self.axjoint[j],
357+
label="q" + str(j),
358+
valmin=qlim[0, j],
359+
valmax=qlim[1, j],
360+
valinit=q[j],
361+
valfmt="% .1f",
357362
)
358363

359364
slider.on_changed(lambda x: update(x, text, robot))

0 commit comments

Comments
 (0)