title: How to add labels to t-SNE in python
body: <p>I'm using t-SNE to searching for relations on a dataset which have seven features.</p>
  
  <p><a href="https://i.stack.imgur.com/JTG4T.png" rel="noreferrer"><img src="https://i.stack.imgur.com/JTG4T.png" alt="enter image description here"></a></p>
  
  <p>I'm using a dictionary to assing colors to the <code>y</code> labels on the plot:</p>
  
  <pre><code>encoding = {'d0': 0, 'd1': 1, 'd2': 2, 'd3': 3, 'd4': 4, 'd5': 5, 'd6': 6, 'd7': 7}
  
  plt.scatter(X_tsne[:, 0], X_tsne[:, 1], c=y['label'].apply(lambda x: city_encoding[x]))
  plt.show()
  </code></pre>
  
  <p>The problem here is that is not clear which color corresponds to which label. The dataset actually has over 100 labels, so it's not something I'd like to handle manually.</p>
  
  <p><a href="https://i.stack.imgur.com/ufAnu.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ufAnu.png" alt="enter image description here"></a></p>