how to plot line with dots?

조회 수: 361 (최근 30일)
Ararat Cetinkaya
Ararat Cetinkaya 2020년 5월 24일
댓글: Star Strider 2020년 5월 24일
I have a two matrix X and Y. I want to make a line graph with dots with plot function.
plot (x,y,'--ok');
it is just plotting black circles but ı want to plot line too with circles.

채택된 답변

Star Strider
Star Strider 2020년 5월 24일
There are several options:
x = 1:10;
y = rand(1,10);
subplot(3,1,1)
plot(x, y, '-ok')
title('Circles and Lines')
subplot(3,1,2)
plot(x, y, 'ok', 'MarkerFaceColor','k')
title('Filled Circles')
subplot(3,1,3)
plot(x, y, '.k')
title('Dots')
One of those (or a combination of them) should do what you want.
.
  댓글 수: 2
Ararat Cetinkaya
Ararat Cetinkaya 2020년 5월 24일
I guess plot(x, y, '-ok') this one is not working in while loop with hold on .
Star Strider
Star Strider 2020년 5월 24일
If you are plotting individual points in a loop, it is not possible to plot lines connecting them, since that is only possible when plotting two or more points. It is necessary to save the data as a vector, and then plot it after the loop completes.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by