choose line color based on intensity

1 次查看(过去 30 天)
Hi,
I have a plot with several concentric circles, and a vector C which gives a value for each radius used. I would like each circle in the plot to have a color based on the intensity specified by C. Is there a way to do this?
Thanks!

回答(2 个)

Image Analyst
Image Analyst 2015-11-25
Maria: You can use the 'EdgeColor' property of rectangle() to draw circles in different colors. You can use the built-in colormap palettes, like jet() or hsv() or hot() or whatever, to create a list of colors. See this code:
numRadii = 20;
colors = jet(numRadii);
xCenter = 50;
yCenter = 60;
for r = 1 : numRadii
leftTopWidthHeight = [xCenter-r/2, yCenter-r/2, r, r];
rectangle('Position', leftTopWidthHeight,...
'Curvature', [1 1], ...
'LineWidth', 4, ...
'EdgeColor', colors(r, :))
hold on;
axis equal
end
grid on;
% Set up figure properties:
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
% Get rid of tool bar and pulldown menus that are along top of figure.
set(gcf, 'Toolbar', 'none', 'Menu', 'none');
% Give a name to the title bar.
set(gcf, 'Name', 'Demo by ImageAnalyst', 'NumberTitle', 'Off')

Haneya Qureshi
Haneya Qureshi 2017-6-21
I am having the same problem, but I would like to color each circle according to the intensity associated with it. In other words, I have 10 circles, each with a certain radius and each radius represents a certain intensity. I would like to color circles according to that intensity and then display a colour map of intensity
  1 个评论
Image Analyst
Image Analyst 2017-6-22
Translate the radius to a row in your colormap and use that color. For example if you have radii that go from 1 - 500, and your radius is 73, and your colormap has 256 rows, then the row containing the color you want to use is
colormapRow = round( (73/500) * 256 );
colorToUse = yourColorMap(colormapRow, :);

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Colormaps 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by