Hello!
I need to plot x and y coordinates over a figure representing a map, which will be displayed at a viewport on the rightop of the figure.
However, when I use the code below, it works, but y coordinates of the points are flipped. Using only the first three lines of the code places the figure properly; using the code without the image function places the points in the correct position. When I run the whole code, y-axis flips and y-coordinates are plotted flipped. I tried set(gca,'Ydir','reverse'), but it did not work.
Any help?
Thanks.
ha2=axes('position',[0.75, 0.55, .22,.42,]); % position of the viewport
image(mapabase,'XData',[-49.7 -48.7],'YData',[1.12 1.67]) %image workin as a map
hold on
for k=1:1:qtde_psgns
plot(navios_cel{k}(:,4),navios_cel{k}(:,3),'.','markers',5); %coordinates of several surveys
end
grid on
hold off
xlim ([-49.7 -48.7])
ylim ([1.12 1.67])

 採用された回答

Adam Danz
Adam Danz 2019 年 8 月 20 日

0 投票

"I tried set(gca,'Ydir','reverse'), but it did not work."
That's because for image() plots the ydir is already set to 'reverse'. You want to set it to 'normal'.
ha2.YDir = 'normal'
% or
set(ha2, 'YDir', 'normal')

4 件のコメント

Diego Fonseca
Diego Fonseca 2019 年 8 月 20 日
編集済み: Diego Fonseca 2019 年 8 月 20 日
Thanks for your answer. However, when I apply ha2.YDir = 'normal', the points x and y are plotted properly, but the image flips. Is there anyway of having both (figure and points) plotted in the proper direction as I want them to represent a map?
Adam Danz
Adam Danz 2019 年 8 月 20 日
編集済み: Adam Danz 2019 年 8 月 20 日
Yes! :)
You can follow this demo.
The key is to use flipud() to flip the data prior to executing imagesc().
Diego Fonseca
Diego Fonseca 2019 年 8 月 20 日
Thanks a lot. It worked perfectly!!!
Nice! ;)
Adam Danz
Adam Danz 2019 年 8 月 20 日
High five!

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

その他の回答 (0 件)

カテゴリ

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

製品

リリース

R2017b

質問済み:

2019 年 8 月 20 日

コメント済み:

2019 年 8 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by