0

I want to create a colormap like heatmap but the colors are defined as a RGB values in a data. Each cell contains specific color value which are needed to be plotted in the image. enter image description here

I want to plot these values that looks like similar to this:

enter image description here

How to generate this kind of colormap without using matplotlib tables. I have accomplished this using matplotlib table by taking reference from here: matplotlib table color

But I want to implement this without using tables. Is these any method other than using matplotlib tables.

sk3145
  • 174
  • 18

1 Answers1

0

It wasn't a color bar, was it? If you can create an RGB relationship with the data, you can express it. I set 'c=colors', but I think it would be better to specify a column with RGB converted to hexadecimal.

import numpy as np
import pandas as pd

import matplotlib.pyplot as plt
import matplotlib.cm as cm
import matplotlib.colors

data = [np.random.randn(50),np.random.randn(50),np.random.randint(1,5,(50,))]

fig = plt.figure(figsize=(10,7))

# RGB:[[100,125,200],[100,125,100],[100.25.50],[122,125,10],[100,25,201]]
# hex=(['#647dc8','#647d64','#641932','#7a7d0a'])
colors = ["#647dc8","#647d64","#641932","#7a7d0a","#ff19c9"]*10

cmap = matplotlib.colors.LinearSegmentedColormap.from_list("", colors)
im = plt.scatter(data[0], data[1], c=colors, linewidths=5, alpha=1.0)

plt.show()

enter image description here

r-beginners
  • 31,170
  • 3
  • 14
  • 32
  • In your example, data variables are filled with random points data but for my case, data variable are filled with individual RGB values which are needed to be converted and display as colormap. I don't need colorbar so it can be neglected. – sk3145 May 17 '20 at 08:00