umap
umap copied to clipboard
umap.plot got the legend blocking some data points
How do I configure the legend position, at least moving it outside of the main figure? I am in Ubuntu and running the following source code from shell.
import numpy as np import sklearn.datasets import umap import umap.plot
data, labels = sklearn.datasets.fetch_openml( 'mnist_784', version=1, return_X_y=True )
mapper1 = umap.UMAP().fit(data)
umap.plot.points(mapper1, labels=labels) umap.plot.plt.show()
It is a matplotlib figure, you you can use the standard matplotlib commands to handle the legend. For example adding a line with:
plt.legend(bbox_to_anchor=(1, 1.05), loc=2)
might do the job.
plt.legend seems to error with "No handles with labels found to put in legend."
Does umap.plot.points return a matplotlib Axis object?
- Trying to treat it as an Axis object and extracting label handles doesn't seem to work either.
In practice you may need to create your own handles to pass to legend
. This is, obviously, not ideal but it should work. Ultimately this is not meant to be a comprehensive plotting library -- more just helper functions to get things up and running quickly. If you really need custom plotting I would suggest just going to matplotlib or datashader directly. Sorry I can't be more help.
same problem.