title: Python: Plot a sparse matrix
body: <p>I have a sparse matrix X, shape (6000, 300). I'd like something like a scatterplot which has a dot where the X(i, j) != 0, and blank space otherwise. I don't know how many nonzero entries there are in each row of X. X[0] has 15 nonzero entries, X[1] has 3, etc. The maximum number of nonzero entries in a row is 16.</p>
  
  <p>Attempts:</p>
  
  <ul>
  <li><code>plt.imshow(X)</code> results in a tall, skinny graph because of the shape of X. Using <code>plt.imshow(X, aspect='auto)</code> will stretch out the graph horizontally, but the dots get stretched out to become ellipses, and the plot becomes hard to read.</li>
  <li><code>ax.spy</code> suffers from the same problem. </li>
  <li><code>bokeh</code> seems promising, but really taxes my jupyter kernel. </li>
  </ul>
  
  <p>Bonus:</p>
  
  <ul>
  <li>The nonzero entries of X are positive real numbers. If there was some way to reflect their magnitude, that would be great as well (e.g. colour intensity, transparency, or across a colour bar).</li>
  <li>Every 500 rows of X belong to the same class. That's 12 classes * 500 observations (rows) per class = 6000 rows. E.g. X[:500] are from class A, X[500:1000] are from class B, etc. Would be nice to colour-code the dots by class. For the moment I'll settle for manually including horizontal lines every 500 rows to delineate between classes. </li>
  </ul>