필터 지우기
필터 지우기

choose line color based on intensity

조회 수: 3 (최근 30일)
María Jesús
María Jesús 2015년 11월 25일
댓글: Image Analyst 2017년 6월 22일
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에서 Blue에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by