choose line color based on intensity
1 view (last 30 days)
Show older comments
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!
0 Comments
Answers (2)
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')
0 Comments
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
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, :);
See Also
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!