Seite 1 von 1

einzelne Farbe in colormap ändern

Verfasst: Montag 8. März 2010, 23:49
von compy
Hallo,

ich möchte in einem contourf-Plot mit einer Standard colormap eine einzelne Farbe durch eine Eigene ersetzen.
z.B. Die 10.te Farbe (von 21) soll schwarz werden.

Geht so etwas oder muß ich eine komplett eigene colormap schreiben.

Code: Alles auswählen

from matplotlib import pyplot as P
import numpy as np
import matplotlib.cm as cm

N = 100
x = np.linspace(-3.0, 3.0, N)
y = np.linspace(-2.0, 2.0, N)

X, Y = np.meshgrid(x, y)
z = X*Y

cmap=P.cm.jet
cs = P.contourf(x,y,z,21,cmap=cmap)
P.colorbar()
P.show()