Plot a line parallel to map axis

Hello:
I wish to plot a straight line parallel to the tropics, i.e., [0,0] to [-180, 180] over the world map defined over map axis ax. I have tried geoplot but its not working. Pls. advice. I also want to set different colors and line thickness and plot another set of lines parallel to tropics but across [-23,23] to [180,180] showing tropical regions.

 Respuesta aceptada

Dyuman Joshi
Dyuman Joshi el 2 de Sept. de 2023
Editada: Dyuman Joshi el 2 de Sept. de 2023
Answer according to the information available -
figure
%Create map axes
mx1 = mapaxes;
land = readgeotable("landareas.shp");
%plot world map
geoplot(land)
hold on
%Add plots for tropical lines
geoplot([23 23],[-180 180],'r-','LineWidth',1)
geoplot([-23 -23],[-180 180],'g--','LineWidth',1.5)

5 comentarios

Poulomi Ganguli
Poulomi Ganguli el 2 de Sept. de 2023
Editada: Poulomi Ganguli el 2 de Sept. de 2023
I have used the worldmap function to plot the global map. I have used the coast file from the available shapefiles. But if I use geoplot and above commands, it doesn't show up.
It says the following:
ax=axesm('mercator','MapLatLimit',[-65 65],'MapLonLimit',[-180 180]);
f=worldmap([-60 80],[-180 180]);
h = geoshow(coast, 'DisplayType', 'polygon','facecolor','w');
Error using geoplot (line 98)
Adding GeographicAxes to axes is not supported. Turn hold off.
Dyuman Joshi
Dyuman Joshi el 2 de Sept. de 2023
You will have to provide more information as to what you are trying to do.
What is the variable 'coast'? Did you load the coastlines data file?
Any particular reason to use axesm?
Poulomi Ganguli
Poulomi Ganguli el 2 de Sept. de 2023
Coastlines data files are loaded previously. There is a reason to use axesm. I need to show certain values based on their values/attributes.
Dyuman Joshi
Dyuman Joshi el 2 de Sept. de 2023
Editada: Dyuman Joshi el 2 de Sept. de 2023
@Poulomi Ganguli How about this?
ax=axesm('mercator');
f=worldmap([-60 80],[-180 180]);
load coastlines
geoshow(coastlat, coastlon)
%Define coordinates for tropical lines
yvec = -180:180;
xvec = ones(size(yvec));
geoshow(23*xvec,yvec,'DisplayType','Line','LineWidth',0.75,'Color',[1 0 0])
geoshow(-23*xvec,yvec,'DisplayType','Line','LineWidth',1.5,'Color',[0 1 0],'LineStyle','--')
Poulomi Ganguli
Poulomi Ganguli el 2 de Sept. de 2023
The second solution works.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Geographic Plots en Centro de ayuda y File Exchange.

Productos

Versión

R2022a

Preguntada:

el 2 de Sept. de 2023

Comentada:

el 2 de Sept. de 2023

Community Treasure Hunt

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

Start Hunting!

Translated by