MATLAB: How to plot multiple 3d plots using the ‘geoplot3’ and ‘geoglobe’ functions

3dplotgeoglobegeographicgeoplot3Mapping Toolboxmultipleoverrideplotsrotationuifigure

Best Answer

There are two things to keep in mind while using the 'geoglobe' function to plot multiple plots:
1. Firstly, the 'geoglobe' function has a default property of deleting existing plots and reset globe properties, except Position and Units, to their default values before displaying the new plot. In order to allow multiple plots to be plotted on the globe the user needs to specify the 'NextPlot' name-value pair argument as 'add' as shown below in the example:
uif = uifigure;
g = geoglobe(uif,'NextPlot','add');
Additionally, please refer to the following documentation regarding the NextPlot property:
2. Secondly, only certain 'hold' syntaxes are supported by the 'geoglobe' function as shown below:
hold(g) %toggles the state between off and on
hold(g,'on') % retains plot so that new plots can be added to the same plot
hold(g,'off') % releases the current plot
Please refer to this documentation link which describes the supported 'hold' syntax:
Additionally, please refer to this sample MATLAB code that will demonstrate how to plot multiple line plots over a local region using the 'geoplot3' function:
trk = gpxread('sample_mixed','FeatureType','track');
lat = trk.Latitude;
lon = trk.Longitude;
h = trk.Elevation;
lat1 = 0.98*(trk.Latitude);
lon1 = 0.98*(trk.Longitude);
h1 = 0.98*(trk.Elevation);
uif = uifigure;
g = geoglobe(uif,'NextPlot','add');
mskip = 1:25:length(lat1);
Resulting figure: