Polar Coordinates: filling the areas with RGB color matrix

10 views (last 30 days)
Ignacio Lobato
Ignacio Lobato on 21 Apr 2015
Commented: Ignacio Lobato on 21 Apr 2015
Hi! I am trying to do a plot like this in Matlab:
There are channels filled with color, in each of the two outter rings there are 32 channels , in the inner rings the number of channels is 8, the total number of channels is 80. Depending on the intensity, the channels are filled with a different color using the RGB scheme. I want to create in Matlab such a plot like the image above, in which Matlab reads the intensity of a specific channel and colors it according to the colormap. My code is the following:
%Make a colormap
number_of_colors=100;
colm = jet(number_of_colors); % choose colorbar (jet)
%Values for indices
values = transpose(Intensities()); % your data
values_min = MinWert; % range of the colorbar (defined in another function)
values_max = MaxWert;
% Calculate the respective index in the colormap for every value
idx_in_colorbar = floor(1+ (values - values_min) / (values_max -...
values_min) * (number_of_colors-1));
% Convert value of index to RGB matrix
RGB=ind2rgb(idx_in_colorbar, colm);
RGB= squeeze(RGB)
figure1=figure(1)
imshow(imagePATH);
hold on
title('Lightintensity of the channels')
%%Lets say we want to create the outter ring here, we have to divide 360° between the 32 channels, and fill from channel 1 to channel 32 the channels, taking the space between r0 and r1 and varying phi (so to say an integral plot filling the area with a color). The color for each channel is taken from the matrix RGB(80x3 matrix). I would use here "patch" but I am not sure how to use it for this case with the polar coordinate plot.
colormap(colm)
colorbar
caxis([handles.MinWert handles.MaxWert]);
This is the array in which the intensities are stored.
Intensities()=
Columns 1 through 8
490.82 90.599 920.77 835.62 831.71 15.219 95.392 899.49
Columns 9 through 16
728.96 844.82 850.07 745.92 798 827.29 837.52 814.13
Columns 17 through 24
880.9 107.99 879.32 938.49 764.72 819.25 799.06 696.44
Columns 25 through 32
715.71 108.02 1003.8 975.19 108.35 847.28 127.63 115.78
Columns 33 through 40
116.58 785.75 973.51 902.83 949.07 946.87 937.79 823.59
Columns 41 through 48
134.26 802.52 974.8 113.26 111.81 888.03 950.62 998.49
Columns 49 through 56
949.09 108.25 987.21 702.57 776.54 791.86 920.16 822.43
Columns 57 through 64
880.79 932.58 893 842.08 490.42 816.86 866.54 712.23
Columns 65 through 72
789.7 730.06 775.99 765.73 676.22 689.65 550.01 846.52
Columns 73 through 80
942.06 612.33 92.245 872.52 923.83 88.743 672.14 622.6
Thanks for your help!

Answers (1)

Michael Haderlein
Michael Haderlein on 21 Apr 2015
Edited: Michael Haderlein on 21 Apr 2015
You can use patches, exactly. Here is an example for the outer ring, I assume that it reaches from r=0.8 to r=1.
phi=linspace(0,2*pi,33);
Phi=[phi(1:end-1);phi(1:end-1);phi(2:end);phi(2:end)];
R=[.8;1;1;.8]*ones(1,32);
x=R.*cos(Phi);
y=R.*sin(Phi);
intensity=ones(4,1)*rand(1,32);
figure, patch(x,y,intensity), axis equal
I think based on this the remaining rings should be straight-forward.

Community Treasure Hunt

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

Start Hunting!