1

I am using pcolormesh on a 2-D NumPY array of points M, so

pcolormesh(X,Y,M)

plots a grid of colors where the X-axis range labels correspond to X[i], Y-axis range labels correspond to Y[j], and the color plotted at point (i,j) corresponds to the level of M[i,j].

I would also like to plot the same thing but where I have a 1-D array M[i], and the color plotted at point (X[i], Y[i]) corresponds to the level of M[i].

I don't see any out of the box solution for this in matplotlib. Is there one? This is the closest I could come up with, taking a cue from an answer to this question:

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.cm as cm

def intensityplot(x,y,z):
    z=z/z.max()
    colors = cm.rainbow(z)
    for X,Y,Z in zip(x,y,colors):
        plt.scatter([X],[Y], color=Z)
Lars Ericson
  • 1,952
  • 4
  • 32
  • 45
  • Matplotlib provides e.g. `tripcolor` or `tricontourf`. Can you go into detail about the requirements and rather ask about actual problems with implementations? – ImportanceOfBeingErnest Jun 26 '19 at 16:34
  • I have an original 4x4 matrix and then I want to subdivide it into 8x8 matrix and plot the points from the original 4x4 matrix, leaving dark spots for what I haven't filled in yet in the subdivided matrix. Since the results above are ugly, what I've done is cleanly subdivided by a factor of two so it is easy to fill in the old points and continue using pcolormesh as before. – Lars Ericson Jun 26 '19 at 16:49

0 Answers0