# Grid colormap with colorized circles

2 views (last 30 days)
RoboTomo on 10 Nov 2022
Commented: Bjorn Gustavsson on 18 Nov 2022
In every node in the grid (9x8) I am rotating some workpiece by 30 degrees and calculating values for every rotation (Fig.1). Each rotation values are stored in sol_mat_MAN_all, and mean values of those 12 rotations are stored in mean_man_all. For every node (plot_points) I plot scatter3 diagram with mean values, so basically one colorized dot is based on mean value of all 12 rotations.
%% PLOT COLORMAP
mean_man_all=mean(sol_mat_MAN_all,2); % Mean rotation value for each grid point
% max_man_all=max(sol_mat_MAN_all,[],2); % Max rotation value for each grid point
%Plot
scatter3(plot_points(:,1),plot_points(:,2),plot_points(:,3),50, mean_man_all,'filled'); %Plot average mean value for every point
xlabel('X [m]'); ylabel('Y [m]'); zlabel('Z [m]');
colorbar; oldcmap = colormap('jet'); colormap(flipud(oldcmap)); hold on;
What I want to do now, is separate rotations and visualize them individually, like some kind of pie chart. Instead of having one colorized dot/circle I want to have this circle cut into 12 pieces where each piece will have its own color based on its rotation value. I have tried some bubble pie plot functions (https://www.mathworks.com/matlabcentral/fileexchange/98874-bubble-pie-chart?s_tid=blogs_rc_5) but I was unable to link values with colormap. Color wheels are also interested but it seems complicated to input my own colormap and plot the whole thing correctly in the grid.
Note that first value is zero rotation (0 degrees) and starts at the right side (Fig.1). My original scatter plot is in 3D where Z-axis is fixed, but here 2D plot is more appropriate. This or something similar should be the final plot, but with correct color for each rotation:

Bjorn Gustavsson on 10 Nov 2022
Something like this shouldn't be too complicated to cook up. Perhaps this is a start:
function h = cwheel(x0,y0,phi0,r,nspokes)
% CWHEEL - simple colour-wheel
%
if nargin < 5 || isempty(nspokes)
nspokes = 18;
end
if nargin < 4 || isempty(r)
r = 1;
end
phi = linspace(0,2*pi,nspokes+1);
[phi,R] = meshgrid(phi,[0 r]);
v = repmat(linspace(0,1,nspokes+1),2,1);
h = pcolor(x0+R.*cos(phi-phi0),y0+R.*sin(phi-phi0),v);
You can run this like this to get something like your second graph:
qwe = peaks(14);
[x0,y0] = meshgrid(1:14);
for i1 = 1:14,
for i2 = 1:14,
h = cwheel(x0(i1,i2),y0(i1,i2),qwe(i1,i2),0.4,12);
hold on
end
end
axis auto
colormap(hsv)
Then if you need different wheels to span different ranges you'll have to add that to the cwheel-function instead of having v span 0-1 every time. You might also prefer to have smoother colour-wheel and only plot a couple of spokes, but that's a minor adjustment (increase the number of elements in v, set shading to flat or interp and plot the spokes you want separately).
HTH
Bjorn Gustavsson on 18 Nov 2022
Great! Happy that it helped.
When it comes to fine-tune figures like this one could take the Leonardo daVinci approach and never be sufficiently happy and continue to tinker till end of time - but that doesn't often justify the effort unless you're Leonardo. But one function you might be interested for this type of plots is rose.
All the best.

### Categories

Find more on Colormaps in Help Center and File Exchange

R2021b

### Community Treasure Hunt

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

Start Hunting!

Translated by