You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importscprepasscprepimportgraphtoolsasgtimportpygspimportnumpyasnpfromsklearnimportdatasetsdata=datasets.make_blobs(n_samples=n_samples, random_state=8)
G=gt.Graph(data)
ax=scprep.plot.scatter2d(data, c=group,
xlabel='x0', ylabel='x1',
title='blobs_regular', figsize=(6,6),
legend=False)
kernel=G.K.toarray()
# This block of code draws lines between each point and its k-nearest neighborsfori, ptinenumerate(data):
neighbors=np.where(kernel[i] >0)[0]
forjinneighbors:
ifi>=j:
continuenn_coordinates=data[j]
ax.plot([pt[0], nn_coordinates[0]], [pt[1], nn_coordinates[1]],
color='k', alpha=kernel[i,j], zorder=0)
ax.set_aspect(1)
produces
The text was updated successfully, but these errors were encountered:
produces
The text was updated successfully, but these errors were encountered: