I am trying to plot a scatter plot where each point in the scatter plot should correspond to a particular shade of a given color of my choice. The mpl documentation states that if I set something like:
color = '0.7'
it gives me a shade of grey with that scaled intensity of 0.7
. I am reading the intensity of the colours from an array with values between 0 and 1 and each value corresponds to the intensity of that point in the scatter plot. My code below is as follows:
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
import math
tsne_embeddings = np.load("tsne_embeddings.npy")
labels = np.load('labels.npy')
weights = np.load('weights.npy')
# Scale the weights from 0 to 1
max_weight = max(weights)
min_weight = min(weights)
weights = (weights - min_weight)/(max_weight - min_weight)
print(tsne_embeddings.shape)
x = list(tsne_embeddings[:,0])
y = list(tsne_embeddings[:,1])
labels = list(labels)
weights = np.round(weights,decimals=2)
weights = (np.exp(weights) - 1)/(np.exp(1) - 1)
weights = list(weights)
print(min(weights),max(weights))
for i, shade in enumerate(weights):
plt.scatter(x[i],y[i],color=shade,marker = '+')
plt.show()
I am scaling those weights exponentially hoping for a better variation. So, essentially, my questions are:
- How do I change the color to say shades of blue or red or green as opposed to just greyscale?
- Is the approach which I follow for greyscale correct?
Thank you!