八度(MATLAB),散点图图例和填充不起作用

我正在使用Octave,它是免费的伪MATLAB。 我的问题是:我想填补散点图的气泡,以及放置一个传奇。但是当我尝试使用'填充'时我会遇到错误,当我使用图例(...)时没有传说。 我的部分代码如下所示:
%ALL SAMPLES, PHI(Signal) @ THETA(Sample)=0
figure(5)
plot( Angles(:,1)([18:27]),  ALL([18:27]), 10, [1 0 1]);  %Magenta
hold on 
scatter(Angles(:,1)([68:76]), ALL([68:76]), 10, [0 0 0]);   %Black
scatter(Angles(:,1)([86:95]), ALL([86:95]), 10, [1 0 0]);   %Red
scatter(Angles(:,1)([119:127]), ALL([119:127]), 10, [0 1 0]);   %Green
scatter(Angles(:,1)([133:141]), ALL([133:141]), 10, [0 0 1]);   %Blue
hold off
xlabel('Signal PMT angle (Sample angle at 0)'); 
ylabel('Normalized (signal/monitor) intensity');
legend('Control', 'Control', '1+2','Virgin','Cycle #1', 'Location','NorthEast');
title('Plot of All Samples, "-int Intensity"')
我知道它应该是ѭѭ,但是当我这样做时我会收到错误。此外,一个传奇似乎永远不会出现。 先感谢您。     
已邀请:
显然在Octave中使用
legend
scatter
有问题。根据这篇文章: http://octave.1599824.n4.nabble.com/Legend-in-scatter-plot-td3568032.html 诀窍是使用
plot
函数制作散点图。我编写了以下函数来绘制同一轴上的一堆散点图。 该函数接收一堆相同长度的单元阵列。单元阵列的每个元素对应于单独的系列。该函数返回一个长度相同的单元格数组,其中包含与每个绘图关联的句柄。该函数的参数解释如下:
x_vals
:与x值对应的双精度数组的单元阵列。
y_vals
:与y值对应的双精度数组的单元阵列。
sizes
:表示标记大小的双精度单元格数组。
colors
:长度为3的双数组的单元格数组,表示标记的
[R, G, B]
颜色值。
styles
:表示标记形状的字符串单元格数组。
    function [handles] = scatter_series_set(x_vals, y_vals, sizes, colors, styles)

        N = length(x_vals);

        if ( (~ ( N == length(y_vals))) || (~ ( N == length(sizes)))  || ...
             (~ ( N == length(colors))) || (~ ( N == length(styles))) )
            error('scatter_series_set: all arguments must be cell arrays of the same length');
        end

        %plot the first series
        handles = cell([N, 1]);
        handles{1} = plot(x_vals{1}, y_vals{1});
        set(handles{1}, 'linestyle', 'none');
        set(handles{1}, 'marker', styles{1});
        set(handles{1}, 'markersize', sizes{1});
        set(handles{1}, 'color', colors{1});

        %plot additional series if present
        if N > 1
            hold on;
            for ind = 2:N
                handles{ind} = plot(x_vals{ind}, y_vals{ind});
                set(handles{ind}, 'linestyle', 'none');
                set(handles{ind}, 'marker', styles{ind});
                set(handles{ind}, 'markersize', sizes{ind});
                set(handles{ind}, 'color', colors{ind});
            end
            hold off;
        end
    end
以下示例演示如何使用此函数。
x1 = 0:(2*pi/100):(2*pi);
x2 = 2*x1;
y1 = sin(x1);
y2 = cos(x1);
y3 = sin(x2);
y4 = cos(x2);
names = {'a', 'b', 'c', 'd'};

x_vals = {x1, x1, x1, x1};
y_vals = {y1, y2, y3, y4};
sizes  = {10, 10, 10, 10};
colors = {[1, 0, 0], [0, 0, 1], [0, 0, 0], [0.7071, 0, 0.7071]};
styles = {'^', 's', 'x', '+'}

scatter_series_set(x_vals, y_vals, sizes, colors, styles);

legend(names, 'location', 'southeast');
示例代码生成以下图表:     
以下适用于我:
n = 100;
x = randn(n, 1);
y = randn(n, 1);
S = rand(n, 1)*20;
hold on
scatter(x(1:50), y(1:50), S(1:50), "red", "filled")
scatter(x(51:100), y(51:100), S(51:100), "green", "filled")
hold off
print('-depsc', 'bubbleplot.eps');
但是,我无法添加图例,我没有找到任何错误报告或缺少功能的指示。所以,作为替代方案,我建议在你的情节中添加标记和文字。     

要回复问题请先登录注册