1

我的(示例)数据采用以下格式:

R_min  R_max   θ_min   θ_min   Zones

0   260 0   1.57    114
260 270 0   1.57    106
270 320 0   1.57    107

如您所见,我有从 R_min 到 R_max 创建的从 theta_min 到 theta_max 的“区域”(区域)。每行数据代表一个我想根据区域编号用相应颜色绘制的区域。在这个简单的例子中,我上面显示的数据如下图所示:

在此处输入图像描述

我应该使用什么绘图软件来完成这个?我一直在研究以下选项:

是否有其他程序或更好的方法来编译我的数据以使我的手头任务可行?

我的真实数据集有数千行数据,并不像四分之一圈彩虹那么简单。

4

2 回答 2

2

这是使用 gnuplot 的一种可能的解决方案。它使用circles绘图样式在原点绘制具有指定半径的重叠楔形。这要求您按最大半径降序对数据进行排序,并且没有间隙。

这是一个可能的脚本:

set xrange [0:350]
set yrange [0:350]

set size ratio -1
set style fill solid noborder
set palette defined (106 'blue', 107 'yellow', 114 'magenta')
set cbrange [106:114]
unset colorbox
plot 'test.txt' using (0):(0):2:($3*180/pi):($4*180/pi):5 with circles linecolor palette notitle

结果(4.6.4):

在此处输入图像描述

还有一些说明:

  • 圆的半径以 x 轴为单位给出,但 y 轴没有相应地调整。这就是为什么您必须同时设置xrangeyrange甚至两个轴的比率都设置为set size ratio -1

  • 使用调色板进行着色是一种选择,其他选项(如使用linecolor variableor linecolor rgb variable)在gnuplot 烛台红色和绿色填充中进行了解释。

  • 在 Unix 系统上,排序也可以即时完成,例如

    plot '< sort -r test.txt' ...
    
于 2014-04-28T06:58:07.650 回答
1

使用 Matlab 使用简单的三角函数和填充实际上很容易做到这一点函数

% R_min  R_max   θ_min   θ_min   Zones
data = [
    0   260 0   1.57    114
    260 270 0   1.57    106
    270 320 0   1.57    107];

% Define a color table, indexed by the "Zones" column
colors = {};
colors{114} = [1.0 0.0 0.5];
colors{106} = [0.7 0.0 1.0];
colors{107} = [1.0 1.0 0.0];

% Define the resolution of the plot (more points = more round)
nPoints = 100;

clf;
hold on;
for i = 1:size(data, 1)
    % Extract the data from the i'th row. There's no need for this, you
    % could access it directly below, but it makes the code more clean. :)
    r_min = data(i,1);
    r_max = data(i,2);
    theta_min = data(i,3);
    theta_max = data(i,4);
    color = data(i, 5);

    % First, get the sine and cosine between theta_min and theta_max
    sin_theta = sin(linspace(theta_min, theta_max, nPoints));
    cos_theta = cos(linspace(theta_min, theta_max, nPoints));

    % Now, draw a semi-circle with radius = r_min and merge this
    % semi-circle with another with radius = r_max, but reversed, so that
    % it begins where the previous semi-circle ended.
    x = [sin_theta * r_min sin_theta(end:-1:1) * r_max];
    y = [cos_theta * r_min cos_theta(end:-1:1) * r_max];

    % Draw the polygon.
    fill(x,y, colors{color}, 'EdgeColor', colors{color});
end
hold off;
axis equal;
grid;
maxRadius = max(data(:,2));
axis([-maxRadius maxRadius -maxRadius maxRadius]);

结果:

在此处输入图像描述

于 2014-04-28T01:58:18.807 回答