choose line color based on intensity

1 visualización (últimos 30 días)
María Jesús
María Jesús el 25 de Nov. de 2015
Comentada: Image Analyst el 22 de Jun. de 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!

Respuestas (2)

Image Analyst
Image Analyst el 25 de Nov. de 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 el 21 de Jun. de 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 comentario
Image Analyst
Image Analyst el 22 de Jun. de 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, :);

Iniciar sesión para comentar.

Categorías

Más información sobre Colormaps en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by