Why do all my points not all plot at the same time?

Hi,
I have a ssection of code that includes a for loop that creates points to plot. I am wantinf each point to be plotted at the same time, but after a new one appears the other dissapears. I have used 'hold on' and this seems to have no effects. The section of the loop responsible for the points is as folows:
for m = 1:5
i = randm(m,1);
j = randm(m,2);
Txx = j + 207000 ;
Txy = i + 909000;
Rxx = 208985;
Rxy = 911073;
fprintf('x is %d and y is %d \n',Rxx,Rxy);
R = worldfileread('concord_ortho_w.tfw', 'planar', size(ortho));
figure (1)
mapshow(ortho, cmap, R);
hold on
plot(Txx, Txy,'g.')
Any help would be greatly appreciated!

回答 (1 件)

Image Analyst
Image Analyst 2021 年 2 月 17 日

0 投票

Your for loop needs an "end". And comment out firugre(1) - not sure if that messes up the hold now, plus it's not needed. Also if you want it to plot after each iteration use drawnow:
drawnow;

3 件のコメント

Oscar Zampi
Oscar Zampi 2021 年 2 月 17 日
Hi, using drawnow doesn't seem to fix the issue - the previos point still gets removed when the new one is added
Walter Roberson
Walter Roberson 2021 年 2 月 17 日
You are displaying the same map each time. That is going to draw on top of the existing axes, hiding any solid area beneath it.
You should display the map once and then loop drawing the points on top.
Oscar Zampi
Oscar Zampi 2021 年 2 月 17 日
Hi, yes I have realised my mistake! I just needed to display the map before the loop, this has sorted it out. The inclusion of drawnow has also worked.
Thank you for your help!

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeGraphics Performance についてさらに検索

質問済み:

2021 年 2 月 17 日

コメント済み:

2021 年 2 月 17 日

Community Treasure Hunt

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

Start Hunting!

Translated by