Hi
I have matrix A(20,100) and I want to plot first column with respect to second column but I do not want to connect the points together. I mean I just want to put these point on the graph I used
plot(A(:,1),A(:,2))
but this command connect points together
How I can do that?
Regards

 Akzeptierte Antwort

Walter Roberson
Walter Roberson am 30 Okt. 2015

1 Stimme

scatter(A(:,1),A(:,2))

3 Kommentare

Ali Kareem
Ali Kareem am 30 Okt. 2015
Hi,
Thank you for your reply. Please how I can add legend for it. I already have another line on the graph and it has legend. Regards
scatter() creates a single graphics handle. You can go ahead and legend() passing in multiple legend entries. For example,
plot(A(:,1), fitted_values);
hold on
scatter(A(:,1), A(:,2));
legend({'Fitted', 'Raw Data'})
Note: if you want different legends for different points you will need to use multiple scatter() calls.
Ali Kareem
Ali Kareem am 30 Okt. 2015
Thank you!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (2)

Hazem
Hazem am 5 Dez. 2017

3 Stimmen

plot(A(:,1),A(:,2), 'o')
or whatever marker you want to use
Daniel Malo Osorio
Daniel Malo Osorio am 29 Apr. 2020

0 Stimmen

Follow-up question
How do I make it possible to plot with lines conecting my dots with the plot() function?
I have tried using the 'r.-' marker, but it ONLY plots the dots on the figure.
assuming x and y are my data vectors
plot(x,y,".-r")

1 Kommentar

Hannes Morgenroth
Hannes Morgenroth am 15 Okt. 2020
Bearbeitet: Hannes Morgenroth am 15 Okt. 2020
I always use hold and plot on top without a marker.
Example:
plot(x,y,".-r")
hold all;
plot(x,y)

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by