简体   繁体   中英

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.

你几乎就在那里,只需更改MarkerSize属性:

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

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

help scatter

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

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

在此输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM