按聚类为极坐标图着色

Colorizing polar plot by clusters

我有一个极坐标图(见下文)。我想按点簇(大约 0 度、60 度、90 度、180 度、270 度和 330 度)为图着色。我试图找到某种功能,但找不到。有什么方法可以实现吗?

编辑:使用命令生成的极坐标图

polar(azi*pi/180,mean_res,'.');

您可以使用 hold onpolar 来绘制不同的颜色:

如何将您的数据分成四个部分取决于您的(未发布的)数据。

% Example data (MathWorks)
theta1 = 0:0.01:pi;
theta2 = pi:0.01:2*pi;
rho1 = sin(2*theta1).*cos(2*theta1);
rho2 = sin(2*theta2).*cos(2*theta2);

% Plot
figure
polar(theta1,rho1,'r*');
hold on;
polar(theta2,rho2,'b*');

最简单的方法是根据您的范围标准将数据分类为子集,然后将它们单独绘制在同一图上(使用 "hold" 函数)。

不能直接在polar函数中添加颜色属性,所以需要捕获绘图句柄,绘图后修改如下:

hp = polar(theta,rho,'.');
hold on
set(hp,'Color',[1 0 0]);
hp2 = polar(theta2,rho2,'.');
set(hp2,'Color',[0 1 0]);

等等。

如果您想要一些微妙的东西,而不仅仅是 'r'、'g'、'b' 和绘图命令。