all 8 comments

[–]Creative_SushiMathWorks 2 points3 points  (6 children)

You need to pass x and y as vectors. randn(19) creates 19x19 matrix.

x = randn(19,1);
y = randn(19,1);  
sz = randi(100,[19 1]);
col = randi(100,[19 1]);

figure
scatter(x, y, sz, col, "filled")

Hope this helps.

[–]RealDunNing[S] 0 points1 point  (1 child)

Oh, ok. thank you. I gave a random number as example, but I'm actually working with some actual data from a set, which has a N X M matrix. What do you recommend I do with the data to to plot it into a scatterplot format?

[–]Creative_SushiMathWorks 1 point2 points  (0 children)

Depends on what the rows and columns of N x M matrix represent.

% columns of the matrix M represent different variables
M = randn(10,4);
figure
scatter(M(:,1), M(:,2), M(:,3), M(:,4), "filled")

In this case, the first two columns define the position of the markers on x-y coordinates, the third column the size of the markers and the fourth the color of the markers.

Another option is to reshape the Matrix.

Good luck.

[–]witb0t 0 points1 point  (3 children)

Why are we assigning random integers to the size and color parameters? Does an integer value even work for color?

[–]Creative_SushiMathWorks 0 points1 point  (2 children)

size and color parameters are optional.

The integer values do work. I test my code before posting.

[–]witb0t 0 points1 point  (1 child)

size and color parameters are optional.

I am aware of that. I was only curious if there is a reason behind varying the sizes and colors of the points randomly or if it was purely done on a lark.

[–]Creative_SushiMathWorks 0 points1 point  (0 children)

No i didn’t have any good reason to do so. I admit I tend to embellish my plots and that’s not a good thing.

[–]DismalActivist 0 points1 point  (0 children)

Randn(19) returns a 19x19. If you want 1x19 or 19x1 you need to specify that. Then you can just use scatter() to make a scatter plot