Grid colormap with colorized circles
8 次查看(过去 30 天)
显示 更早的评论
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
load sol_mat_MAN_all.mat; % Load rotation values
load plot_points.mat; %Load plot points
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;
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1187823/image.jpeg)
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1187828/image.jpeg)
0 个评论
采纳的回答
Bjorn Gustavsson
2022-11-10
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
4 个评论
Bjorn Gustavsson
2022-11-18
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Purple 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!