0

I'm trying to plot features matrix and labels array together with scatter plot. (basic machine learning tutorial)

The feature matrix was built in this way:

  • the rows defines file names and the rows defines the words from dictionary.
  • the values in the matrix contains the count of each word in the file.
  • the size of the matrix is [N*M]

The labels was built in this way:

  • vector (matrix (1:M)) were each value contains 1 or 0

I want to visual the feature matrix and it's labels so scatter plot seems the right way.

I used 'matshow' to plot the matrix but I have troubles to connect to the labels.

For simple example I have tried to test with simple code:

import numpy as np
mat = np.zeros((5, 10))
arr = np.zeros(5)

mat[1,1] = 7
mat[3,3] = 9
mat[1,2] = 2
mat[1,4] = 20
mat[2,3] = 1

arr[1] = 1
arr[3] = 1

import matplotlib.pyplot as plt
#plt.scatter(x, y)
plt.matshow(mat)
plt.show()

So how can I plot the matrix and show the labels in scatter matrix (or other appropriate plot)

Scott Hunter
  • 48,888
  • 12
  • 60
  • 101
user3668129
  • 4,318
  • 6
  • 45
  • 87
  • Possible duplicate of https://stackoverflow.com/questions/3529666/matplotlib-matshow-labels – Sheldore Jun 14 '19 at 13:19
  • You wrote *but I have troubles to connect to the labels.* and then *show the labels in scatter matrix*. Both statements are unclear and they don't explain anything what you mean. Are you talking about annotations? Are you talking about x- and y-tick labels? Include some sample output figure which you want to have. Figure speaks better than words – Sheldore Jun 14 '19 at 13:19

0 Answers0