我有两个数据集。其中详细列出了 angles
的列表(我正在绘制玫瑰图):
angles
-0.8481065519
0.0367932161
2.6273740453
...
n
另一个,从这组角度详细说明方向统计:
angle,error
-0.848106563,0.8452778824
哪里angle
本质上定义了方向平均值,并且 error
圆形方差,本质上是 angle
两侧的误差条
到目前为止,我已经使用一组角度绘制了玫瑰直方图,如下所示:
h = rose(angles,36)
我想创建方向统计图 angle
(它不需要长度/大小 - 只需到圆形图的边缘)与 error
周围。
举个例子:
我在 Matlab 中手动添加了这些行。如果可能的话,最好在弧线内也有阴影。或者,(可能是首选)是在玫瑰图箱上方有一 strip 中心线的条子(因此它不会覆盖数据)(显示 angle
和 error
的阴影周围。
提前致谢。
最佳答案
这个怎么样?
%// Data
angles = 2*pi*.8*randn(1,1e4);
angle = -0.848106563;
error = 0.8452778824;
%// Plot rose
rose(angles, 36);
axis image %// make axis square
hold on
%// Plot mean
a = axis;
a = a(2); %// size of axis
plot([0 cos(angle)*a], [0 sin(angle)*a], 'r')
%// Plot error as many shaded triangles that compose a circular wedge
t = linspace(-error/2+angle,error/2+angle,100); %// increase "100" if needed
for k = 1:numel(t)-1
h = patch([0 cos(t(k))*a cos(t(k+1))*a 0], ...
[0 sin(t(k))*a sin(t(k+1))*a 0], [.5 0 0], 'edgecolor', 'none');
%// change color [.5 0 0] to something else if desired. Note also alpha
set(h,'Facealpha',.3) %// make transparent
end
%// Place rose on top by rearranging order of axis children
ch = get(gca,'children');
set(gca,'children',[ch(2:end); ch(1)]);
为此,您需要使用具有透明度的图形渲染器。因此您可能需要调整图窗的 renderer
属性。
关于matlab - 将向量(或弧)绘制到玫瑰图上。 MATLAB,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23660867/