It has been a while since I played around with this, and I am working completely off my memory right now, but here goes…
If I remember correctly, the ‘c’ values can be an array that is parallel to the x, y, z arrays and specifies the color in one of two ways. First, the array could have a list of color specs (e.g., ‘k’, ‘r’, ‘b’). Second, the array could contain values that would be passed to the colormap to retrieve the colorspec according to where the value lies on the scale of 0 to 1.
If you want to use just simple colors, go ahead and just make a list of characters like so:
[‘k’, ‘r’, ‘g’, ‘g’, ‘b’, ‘k’]
based on whatever the values are in z (I recommend using numpy’s where() function for this.
I am not 100% sure if you need the following or if mpl will just autoscale for you. So you might want to first just try out using the ‘c’ keyword.
If you want to use the colormap, then the values passed into c either has to be the normalized values of z
c = (z - z.min()) / (z.max()-z.min())
or you can use one of the Normalize classes in matplotlib.color (assuming you have imported matplotlib.pyplot as plt):
norm = plt.Normalize(z.min(), z.max())
or whatever minimum and/or maximum values you wish.
I believe you can use the default colormap by not specifying anything at all for cmap, but I could be wrong here. You can also specify any colormap by their name like ‘spring’, ‘jet’, ‘bone’ and so on.
I hope that helps.
On Wed, Oct 13, 2010 at 5:46 PM, Pedro M. Ferreira <pmffferreira@…287…> wrote:
I have been trying to make a 3D scatter plot using mplot3d and I would
like the markers to have their colour according to the Z value.
From what I understood in the tutorial and API I have to use the cmap
and norm kwargs, but all my attempts failed.
I am trying to do it like this:
However I am not sure what to pass to c, cmap and norm.
Any help ?