Right now my data looks like this:
nn = ["1W", "1F", "1V",,,,,"2W", "2F", "2V",,,,,"260W", 261F', "261V",,,,]
Essentially each number has the same number of letters corresponding to it. 19 letters in total. And I have 4798 numbers. Basically, I have 4978*19 points in my list.
I have another list that looks like this:
value=[1.15, 0.67, 0.88..........]
each value corresponds to the character in my nn list. That means I have 4978*19 values in my value list.
Essentially, I want a 2D grid plot with x axis corresponding to the number and y axis corresponding to the letter. Each cell represents the value. I need different colors to present different values. Maybe one color covers a range of values. like red color represents 1-10, blue represents 10-20?? To get a better sense of what I'm trying to plot. I hand drew a plot to visualize.

I could split my nn list into x-aixs and y-axis.
x_axis = [1,2,3,.......4978]
y_axis = ["W", "V", "F", .....] #19 in total
One problem That I may run into is that because I have so many numbers. The plot will look humongous. So maybe I could split one big ass plot into subplots???
Also, some entries in my value list might be missing data, like value[100]=' ', or like value[101]='infinity'. The point is len(value) is still equal to 4978*19. So I also want some color to represent insufficient data.
Given what you've shown of nn, it looks like the corresponding values are in order.
Therefore, I think you could convert your list to a 2D NumPy array
values = np.array(values).reshape((19, 4978))
and then plot them using plt.imshow(values). For example,
import numpy as np
import matplotlib.pyplot as plt
# generate some random values
values = np.random.random(19*4978).tolist()
# convert the list to a 2D NumPy array
values = np.array(values).reshape((19, 4978))
h, w = values.shape
fig, ax = plt.subplots()
plt.imshow(values)
plt.colorbar()
plt.yticks(np.arange(h), list('PNIYLKCVFWABCDEFGHI'))
ax.set_aspect(w/h)
plt.show()

Note that while the default colormap, viridis, is not as colorful as the example
you drew, it does have some very interesting
features. Perhaps the most
important is that the "intensity" of the colors correspond well to a
monotonically increasing scale. Thus you can intuitively "read off" the value
represented by the colors in the plot. The same could not be said of a plot using
the colorful jet colormap, or a colormap like the one you proposed where 1--10 is
colored red and 10--20 is colored blue, etc. The reader would be forced to
constantly refer to the colorbar or a legend to check the correspondences between
colors and values.
import seaborn as sns
import numpy as np
n = 12
data = np.random.randint(0,5, (n,n))
Let's consider that where the element value is zero the data is missing (or just None value in its place)
# Creating a mask which will mask your missing data
Mask = np.zeros(np.shape(data))
for i in range(n):
for j in range(n):
if(data[i][j] == 0):
Mask[i][j] = True
else:
Mask[i][j] = False
sns.heatmap(data, mask=Mask, square=True, linewidths=0.01, linecolor='k', cmap='hsv');

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With