dpeerlab / Palantir

Single cell trajectory detection
https://palantir.readthedocs.io
GNU General Public License v2.0
213 stars 50 forks source link

Adding colorbar to plot_gene_expression #47

Closed mcfefa closed 4 years ago

mcfefa commented 4 years ago

Is there a way to produce colorbar with a plot using plot_gene_expression? It tried this, but it didn't work:

palantir.plot.plot_gene_expression(imp_df, tsne, ['CD34'])
plt.colorbar()

Error returned:

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-58-a001565da174> in <module>()
      1 palantir.plot.plot_gene_expression(imp_df, tsne, ['CD34'])
----> 2 plt.colorbar()

/Users/mcfefa/.local/lib/python3.6/site-packages/matplotlib/pyplot.py in colorbar(mappable, cax, ax, **kw)
   2091         mappable = gci()
   2092         if mappable is None:
-> 2093             raise RuntimeError('No mappable was found to use for colorbar '
   2094                                'creation. First define a mappable such as '
   2095                                'an image (with imshow) or a contour set ('

RuntimeError: No mappable was found to use for colorbar creation. First define a mappable such as an image (with imshow) or a contour set (with contourf).
ManuSetty commented 4 years ago

Color bars can be plotted by setting plot_scale=True in the palantir.plot.plot_gene_expression. Please give it a try and let us know if you run into further issues.

mcfefa commented 4 years ago

That worked perfectly, thanks!!