choose line color based on intensity

1 view (last 30 days)
María Jesús
María Jesús on 25 Nov 2015
Commented: Image Analyst on 22 Jun 2017
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!

Answers (2)

Image Analyst
Image Analyst on 25 Nov 2015
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 on 21 Jun 2017
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 Comment
Image Analyst
Image Analyst on 22 Jun 2017
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, :);

Sign in to comment.

Categories

Find more on Colormaps in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!