Mewa
Mewa

Reputation: 502

MATLAB: imagesc() and image() display the same colormap differently

I have some data I would like to display in a picture form. In one case I want to rescale the x and y axis, which leads me to using imagesc. The issue is that the same colormap (jet) looks different in imagesc as compared to image.

Is there a way to make them the same?

I am using MATLAB R2014a.

Demonstration:

Here is how I show them:

figure; image(cancelledmap); colormap(jet);          %image
figure; imagesc(y,x,cancelledmap); colormap(jet);    %imagesc

And the output:

The colormap settings for both figures are somehow the same, however:

image()

imagesc()

Upvotes: 1

Views: 1318

Answers (1)

rlbond
rlbond

Reputation: 67749

imagesc scales the color axis, whereas image does not. That's why the colors look different. If you click the colorbar button you'll see that they are on different color scales.

You can change the colorscale with caxis.

By the way, if you only want to scale the X- and Y-axes, you can use either function. Just supply your own scaled x and y vectors.

Upvotes: 6

Related Questions