imagesc make all negatives values black
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have the following code which is part of a subplot series. I want to change it so that all negative values become a certain colour (preferably black). I am stuck as to how to achieve this.
figure(3)
subplot(3,3,1)
imagesc(coeffA40)
title ('A40 Coefficients')
caxis([minCoeff, maxCoeff])
myColorMap = hsv(256);
myColorMap(1,:) = 1;
colormap(myColorMap);
grid on
ax = gca
ax.LineWidth = .75
ax.GridColor = 'k'
ax.GridAlpha = .2
ax.XTick = [10 20 30 40];
ax.YTick = [10 20 30];
ax.XTickLabel = {'', '', '', ''};
ax.YTickLabel = {'','',''};
ax.TickLength =[0.0 0.0]
ax.XTickLabelRotation = 45
Thank you in advance for any help!
0 comentarios
Respuestas (1)
Image Analyst
el 29 de Mzo. de 2016
Several ways. One is to create a temporary image
displayedImage = coeffA40; % Initialize
displayedImage(displayedImage <=0) = 0;
cmap = jet(256);
cmap(1,:) = 0; % Lowest gray level appears black.
imshow(displayedImage);
colormap(cmap);
colorbar;
Another might be to alter the colormap so that it applies between 0 and the max.
cmap = jet(256);
cmap(1,:) = 0; % Lowest gray level appears black.
imshow(coeffA40);
colormap(cmap);
colorbar;
caxis([0, max(coeffA40(:))]);
(Both of these are untested - just off the top of my head.)
3 comentarios
Image Analyst
el 29 de Mzo. de 2016
Set the nans to the max value (or the white value) before display, something like:
displayedImage(isnan(displayedImage)) = max(displayedImage(:));
Walter Roberson
el 29 de Mzo. de 2016
image(coeffA40, 'AlphaData', double(~isnan(coeffA40)) )
Ver también
Categorías
Más información sobre Blue en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!