0

I'm using the MiniSom package to make a Self Organizing Map of my data, in one of their examples on GitHub they plot a nice static hexagonal topology visualising the distance between the neighbouring neurons using a color based on an array with distance values (floats between 0 and 1) and an overlay of symbols showing the corresponding classes.

(see example here: https://github.com/JustGlowing/minisom/blob/master/examples/HexagonalTopology.ipynb)

I successfully copied this code and applied it to my dataset but now I'd like to alter the code such that I can use a different array to base the colors on, specifically an array with larger values which are not between 0 and 1. I tried doing this by simply exchanging the umatrix by my self-made matrix with different values. See below in a snippet of the example

# iteratively add hexagons
for i in range(weights.shape[0]):
    for j in range(weights.shape[1]):
        wy = yy[(i, j)] * np.sqrt(3) / 2
        hex = RegularPolygon((xx[(i, j)], wy), 
                             numVertices=6, 
                             radius=.95 / np.sqrt(3),
                             facecolor=cm.Blues(umatrix[i, j]),  "___________I replace umatrix here by my own array"
                             alpha=.4, 
                             edgecolor='gray')
        ax.add_patch(hex)

Simply applying the same code to this array with larger values gives the following output: (note, I am not plotting the symbols in this example outcome, only this color)

Output of array with larger values

All non-null hexagons get the same color as the values are all way above 1 in this different array and the colorbar does not adapt automatically. How can I alter this colorbar to fit this different array of larger numbers? Or is there a way to set a min and max of this colorbar? Any help would be appreciated!

Bas R
  • 175
  • 7

0 Answers0