user2178841
user2178841

Reputation: 859

Plotting points while plotting vectors : Matlab

I need to make a plot with only points and tried something like

plot(x,y)

where x and y are vectors: collection of points.

I do not want matlab to connect these points itself. I want to plot as if plotted with

for loop
plot;hold on;
end

I tried

plot(x,y,'.');

But this gave me too thick points.

I do not want to use forloop because it is time expensive. It takes a lot of time.

Upvotes: 3

Views: 1736

Answers (4)

marsei
marsei

Reputation: 7751

You may try this piece of code that avoid using loops. The plot created does not have lines but markers of different colors corresponding to each column of matrices x and y.

%some data (matrix)
x = repmat((2:10)',1,6);
y = bsxfun(@times, x, 1:6);

set(0,'DefaultAxesColorOrder', jet(6)); %set the default matlab color 

figure('Color','w');
plot(x,y,'p'); %single call to plot
axis([1 11 0 70]);
box off;
legend(('a':'f')');

This gives

enter image description here

Upvotes: 1

Dan
Dan

Reputation: 45741

You're almost there, just change the MarkerSize property:

plot(x,y,'.','MarkerSize',1)

Upvotes: 4

Cosades
Cosades

Reputation: 331

help scatter

IIRC: where S is the size of the scatter points: scatter(x,y,S)

Upvotes: 2

AitorTheRed
AitorTheRed

Reputation: 553

Try:

plot(x,y,'*');

or

plot(x,y,'+');

You can take a look to the documentation: http://www.mathworks.nl/help/matlab/creating_plots/using-high-level-plotting-functions.html

Upvotes: 2

Related Questions