Custom colormap being cut off in colorbar

7 Ansichten (letzte 30 Tage)
Pia
Pia am 8 Jan. 2014
Kommentiert: Image Analyst am 8 Jan. 2014
I am trying to plot something with a manually added colormap, using something like the code below (this is just a minimal example showing my problem): I create some kind of matrix that has values between two known values, plot it with pcolor, and insert a colorbar.
Tmin=10; Tmax=320;
colmap = load('colorbartest_colormap.txt');
imagematrix = transpose(sqrt(linspace(Tmin,Tmax,10)))*sqrt(linspace(Tmin,Tmax,10));
pcolor(imagematrix);
colorbar;
This plots nicely with the standard colormap (jet), as shown in the screenshot:
however, if I try to use my own colormap with
colormap(colmap)
I end up with the following:
and actually, even though I just use
colormap('jet')
I still get the problem, as:
Can anyone help me with what happens here? :(
I am using MATLAB vs. R2011a on Windows 7 64bit, if that has any importance.

Akzeptierte Antwort

Image Analyst
Image Analyst am 8 Jan. 2014
You can't have more than 256 color indexes - that's why it stops there.
Also, don't use pcolor() because it doesn't show you all the rows and columns of your image. That's why you see only a 9 by 9 array/grid instead of a 10 by 10 one.
  2 Kommentare
Pia
Pia am 8 Jan. 2014
Ah, then it makes sense - thank you so much for that! :)
Image Analyst
Image Analyst am 8 Jan. 2014
Use image() or imshow() instead of pcolor(). You can have values outside the 0-255 range though. Run my attached demos.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Colormaps finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by