Skip to content

Unable to determine Axes to steal space for Colorbar #509

@JamieEdgar

Description

@JamieEdgar

Describe the bug
ch5.ipynb throws an error where there are colorbars as described below. Adding the cax line to Plannerbase.py eliminates the error.

File ~/.local/lib/python3.13/site-packages/roboticstoolbox/mobile/PlannerBase.py:886, in PlannerBase.plot_bg(self, distance, cmap, ax, inflated, colorbar, block, **unused)
884 scalar_mappable_c_map = cm.ScalarMappable(cmap=c_map, norm=norm)
885 if colorbar is True:
--> 886 plt.colorbar(
887 scalar_mappable_c_map,
888 # shrink=0.75,
889 # aspect=20 * 0.75,
890 label="Distance",
891 #cax=ax.inset_axes([0.95, 0.1, 0.05, 0.8]), # adding this line (uncommented) eliminates the error
892 )
894 elif isinstance(colorbar, dict):
895 if "label" not in colorbar:

ValueError: Unable to determine Axes to steal space for Colorbar. Either provide the cax argument to use as the Axes for the Colorbar, provide the ax argument to steal space from it, or add mappable to an Axes.

Version information

unedited code matches GitHub master version

To Reproduce
Steps to reproduce the behavior:
Just run the notebook for chapter 5.

Expected behavior
Notebook shouldn't throw the error.

Environment (please complete the following information):
Fedora Linux- Your OS (MacOS, Linux, Windows).
3.13.2 - Your Python version.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions