# Octave(MATLAB), scatterplot legend and fill not working

I am using Octave, which free pseudo-MATLAB. My problem is this: I want to fill the bubbles of my scatter plot, as well as place a legend. But I get errors when I try to use 'filled,' and no legend comes up when I use legend(...). Part of my code looks like this:

%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"')

I know it should beplot( Angles(:,1)([18:27]), ALL([18:27]), 10, [1 0 1], 'filled');, but I receive errors when I do that. Also, a legend never seems to show up.

Thank you in advance.

## Answers

Apparently there is a problem with using legend with scatter in Octave. Based on this post:

http://octave.1599824.n4.nabble.com/Legend-in-scatter-plot-td3568032.html

the trick is to use the plot function to make scatter plot. I wrote the following function for plotting a bunch of scatter plots on the same axis.

This function takes in a bunch of cell arrays of the same length. Each element of the cell array corresponds to a separate series. The function returns a cell array of the same length containing the handle associated with each plot. The arguments of the function are explained below:

x_vals: a cell array of arrays of doubles corresponding to x values.

y_vals: a cell array of arrays of doubles corresponding to y values.

sizes: a cell array of doubles representing the size of the markers.

colors: a cell array of double arrays of length 3, representing [R, G, B] color values of the markers.

styles: a cell array of strings representing the shape of the markers.

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

The following example demonstrates how to use this function.

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');

The example code produces the following plot:

The following works for me:

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');

However, I'm not able to add a legend, and I didn't find any bug report or indication of a missing functionality for this. So, as an alternative, I would suggest adding marker and text to your plot.

### Need Your Help

### Setting Sql server security rights for multiple situations

sql-server security windows-authentication sql-server-2008-r2

We have an application which uses an instance of Sql Server locally for its backend storage. The administrator windows login has had its sysadmin right revoked, and instead two sql logins have been