Skip to content

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. #224

@danli349

Description

@danli349

Hello:
Could you please let me know how to solve this problem? Thanks a lot

plot_imputed_features(
    cistopic_obj,
    reduction_name='UMAP',
    imputed_data=imputed_acc_obj,
    features=[markers_dict[x].index.tolist()[0] for x in ['DediffT_C345', 'DiffT_C1', 'Normal_C2']],
    scale=False,
    num_columns=3,
    save = './outs/plot_imputed_features_DediffT_C345.pdf'
)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[53], line 1
----> 1 plot_imputed_features(
      2     cistopic_obj,
      3     reduction_name='UMAP',
      4     imputed_data=imputed_acc_obj,
      5     features=[markers_dict[x].index.tolist()[0] for x in ['DediffT_C345', 'DiffT_C1', 'Normal_C2']],
      6     scale=False,
      7     num_columns=3,
      8     save = './outs/plot_imputed_features_DediffT_C345.pdf'
      9 )

File [~/miniconda3/envs/scenicplus/lib/python3.11/site-packages/pycisTopic/clust_vis.py:845](http://localhost:8888/lab/tree/pycisTopic/~/miniconda3/envs/scenicplus/lib/python3.11/site-packages/pycisTopic/clust_vis.py#line=844), in plot_imputed_features(cistopic_obj, reduction_name, imputed_data, features, scale, cmap, dot_size, alpha, selected_cells, figsize, num_columns, save)
    843 scalarmappaple = cm.ScalarMappable(norm=normalize, cmap=cmap)
    844 scalarmappaple.set_array(color_data)
--> 845 plt.colorbar(scalarmappaple)
    846 if num_columns == 1:
    847     if save is not None:

File [~/miniconda3/envs/scenicplus/lib/python3.11/site-packages/matplotlib/pyplot.py:2533](http://localhost:8888/lab/tree/pycisTopic/~/miniconda3/envs/scenicplus/lib/python3.11/site-packages/matplotlib/pyplot.py#line=2532), in colorbar(mappable, cax, ax, **kwargs)
   2528     if mappable is None:
   2529         raise RuntimeError('No mappable was found to use for colorbar '
   2530                            'creation. First define a mappable such as '
   2531                            'an image (with imshow) or a contour set ('
   2532                            'with contourf).')
-> 2533 ret = gcf().colorbar(mappable, cax=cax, ax=ax, **kwargs)
   2534 return ret

File [~/miniconda3/envs/scenicplus/lib/python3.11/site-packages/matplotlib/figure.py:1273](http://localhost:8888/lab/tree/pycisTopic/~/miniconda3/envs/scenicplus/lib/python3.11/site-packages/matplotlib/figure.py#line=1272), in FigureBase.colorbar(self, mappable, cax, ax, use_gridspec, **kwargs)
   1271 if cax is None:
   1272     if ax is None:
-> 1273         raise ValueError(
   1274             'Unable to determine Axes to steal space for Colorbar. '
   1275             'Either provide the *cax* argument to use as the Axes for '
   1276             'the Colorbar, provide the *ax* argument to steal space '
   1277             'from it, or add *mappable* to an Axes.')
   1278     fig = (  # Figure of first Axes; logic copied from make_axes.
   1279         [*ax.flat] if isinstance(ax, np.ndarray)
   1280         else [*ax] if np.iterable(ax)
   1281         else [ax])[0].get_figure(root=False)
   1282     current_ax = fig.gca()

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions