clarkson
clarkson

Reputation: 571

changing the surface graph colors in matlab

enter image description here]1

In this graph I want to change the surface colors. I want to represent the area in red by blue and the area in blue by red. So in the scale values closer to 1, would be represented by blue color and values closer to 0 by red color. How can I make this adjustment?

Upvotes: 0

Views: 93

Answers (1)

mikkola
mikkola

Reputation: 3476

You can manually modify the colormap to make the adjustment. Let's take an example using the jet colormap.

Here's the original figure:

figure;
surf(peaks);

original with jet

Now we take a jet colormap with 128 values, flip it and assign it to the axes:

cmap = jet(128); %// get colormap you want
cmap = flipud(cmap); %// flip colormap
colormap(cmap); %//assign colormap

Which has the effect desired, blue colour is shown for large values and red for small:

enter image description here

Upvotes: 1

Related Questions