5

The answer to this question illustrates how scatterplot marker colors can be specified by RGB tuples.

Is it possible to something similar for color meshes, where the color of each x,y pair is given by an RGB tuple rather than as a colormap value?

Community
  • 1
  • 1
Alaya
  • 272
  • 1
  • 4
  • 10

1 Answers1

1

I am not sure if pcolormesh can be easily used to create an rgb image (and I'm interested in the answer to that question myself). However, it is relatively easy to create an rgb image with imshow or axes_grid1.axes_rgb. Summarizing more comprehensive tutorials here and here:

import numpy as np
import pylab as plt
from mpl_toolkits.axes_grid1.axes_rgb import RGBAxes

rgb = np.random.random((5, 5, 3))

fig = plt.figure()
ax = RGBAxes(fig, [0.1, 0.1, 0.8, 0.8])
ax.imshow_rgb(rgb[:,:,0],rgb[:,:,1],rgb[:,:,2],interpolation='none')

plt.figure()
plt.imshow(rgb,interpolation='none')

The resulting images are shown below:

axes_rgb imshow_rgb

kadrlica
  • 322
  • 3
  • 15