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

조회 수: 6 (최근 30일)
Thao Linh Tran
Thao Linh Tran 2021년 6월 6일
댓글: Cristina Radin 2022년 2월 2일
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일
coastlon(abs(diff(coastlon))>180+1)=nan;
  댓글 수: 1
Cristina Radin
Cristina Radin 2022년 2월 2일
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일
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
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일
Make sure to clear the figure before plotting because the coast.mat does not have these lines.
  댓글 수: 2
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.

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

Community Treasure Hunt

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

Start Hunting!

Translated by