How to remove horizontal lines as plotting 0-360 degree map

Hi, I am using following codes to plot a 0-360 degree map, can anyone please help to show me how to remove the horizontal lines on the map created. Athough plot(X,Y,'.') does not show those lines, I wanted to plot the coastlines instead of points. Thanks in advance!
Coast=load('Coast.mat');
X=Coast.long;
Y=Coast.lat;
X(X<=0)=X(X<=0)+360;
plot(X,Y);

2 件のコメント

Chunru
Chunru 2021 年 6 月 6 日
If you have mapping toolbox:
f= worldmap('world')
plotm(Coast.lat, Coast.lon)
Thao Linh Tran
Thao Linh Tran 2021 年 6 月 6 日
Thank you but I wanted to use plot instead of plotm.

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

回答 (3 件)

wentao ma
wentao ma 2021 年 12 月 1 日

2 投票

coastlon(abs(diff(coastlon))>180+1)=nan;

1 件のコメント

Hi! You are right, thank you!
The complete code:
load coastlines
coastlonWrapped = wrapTo360(coastlon);
index=abs(diff(coastlonWrapped))>180+1;
pos=find(index==1) %to be sure
pos = 9×1
371 4311 4420 4991 4994 4998 5076 8063 8077
coastlonWrapped(pos)=NaN;
plot(coastlonWrapped,coastlat)

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

KSSV
KSSV 2021 年 6 月 6 日
編集済み: KSSV 2021 年 6 月 6 日

0 投票

Coast=load('Coast.mat');
X=Coast.long;
Y=Coast.lat;
% X(X<=0)=X(X<=0)+360;
X = X+180 ; Y = Y+180 ;
plot(X,Y);

5 件のコメント

Thao Linh Tran
Thao Linh Tran 2021 年 6 月 6 日
Thank you but this gives the [-180,180] map instead of [0 360].
KSSV
KSSV 2021 年 6 月 6 日
Edited the answer.
Thao Linh Tran
Thao Linh Tran 2021 年 6 月 6 日
Hi KSSV, that only changes the Xticklabels not the real longitudes. The purpose is to plot the whole region of the Western North Pacific.
KSSV
KSSV 2021 年 6 月 6 日
180 is added to X and Y, lon and lat are also changed.
Thao Linh Tran
Thao Linh Tran 2021 年 6 月 6 日
But the Western North Pacific is splitted into two parts by that way.

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

SALAH ALRABEEI
SALAH ALRABEEI 2021 年 6 月 6 日

0 投票

Make sure to clear the figure before plotting because the coast.mat does not have these lines.

2 件のコメント

SALAH ALRABEEI
SALAH ALRABEEI 2021 年 6 月 6 日
Thao Linh Tran
Thao Linh Tran 2021 年 6 月 6 日
Thanks, but the purpose is to not split the Western North Pacific into two parts as in your fig.

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

質問済み:

2021 年 6 月 6 日

コメント済み:

2022 年 2 月 2 日

Community Treasure Hunt

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

Start Hunting!

Translated by