Hide (or remove) the geoaxes in geobasemap

How can I hide or remove the geoaxes in my plot? When I use the command:
geobasemap('grayland')
everything works as expected. Indeed, both the map and the axes are visible. However, when I try to hide the axes using the following command, nothing changes:
geobasemap('grayland')
gx = geoaxes;
set(gx,'Visible','off')

5 commentaires

Umar
Umar le 9 Déc 2025

Hi @Sim,

I saw your question about hiding geoaxes and wanted to help clarify what's happening with your code.

The issue is that gx = geoaxes creates a new geographic axes object instead of getting a handle to the existing one that geobasemap('grayland') created or modified. So when you set gx to invisible, you're hiding the new axes, but the original one with the basemap remains visible.

Here are the correct approaches:

Option 1:

%Use gca to get the current axes
geobasemap('grayland')
gx = gca;  % Get current axes (the one created by geobasemap)
set(gx, 'Visible', 'off')

Option 2:

%Direct property access (more concise)
geobasemap('grayland')
gca.Visible = 'off';

Option 3:

%Create axes with properties in one step
gx = geoaxes('Basemap', 'grayland', 'Visible', 'off');

All three methods work correctly and will hide the axes as intended.

Result: for demo,please see screenshot for one of the approach that I used.

According to the MathWorks GeographicAxes Properties documentation ( https://www.mathworks.com/help/matlab/ref/matlab.graphics.axis.geographicaxes-properties.html ), when you call geoaxes without any arguments, it creates a new geographic axes with default values for all properties. The geobasemapfunction works on the current axes, so you need gca to access that same axes object.

Important note about the Visible property:The documentation also mentions that " when the Visible property is 'off', the axes object itself is invisible, but child objects such as lines remain visible." This means setting Visible to 'off' will hide the axes frame, grid lines, tick labels, and basemap, but any data you've plotted (like lines or markers) will still show up. This is actually useful if you want to display just your data without the map background.

Hope this clears things up!

Sim
Sim le 9 Déc 2025
Modifié(e) : Sim le 9 Déc 2025
Thaks a lot for your kind reply @Umar!
Once I tried your 3 options on my machine:
clear all; close all; clc;
% Option 1:
% Use gca to get the current axes
figure
geobasemap('grayland')
gx = gca; % Get current axes (the one created by geobasemap)
set(gx, 'Visible', 'off')
% Option 2:
% Direct property access (more concise)
figure
geobasemap('grayland')
gca.Visible = 'off';
% Option 3:
% Create axes with properties in one step
figure
gx = geoaxes('Basemap', 'grayland', 'Visible', 'off');
I got the following output:
Do you think there is a way to just show the background map (like in my attached Figure 2), but without the axes?
I would like to see only the map.
Umar
Umar le 9 Déc 2025

Hi @Sim, Thanks for your kind words. Looks like you’ve nailed it! The approach you found, using set(gx.LatitudeAxis, 'Visible', 'off') and set(gx.LongitudeAxis, 'Visible', 'off'), along with set(gx, 'Box', 'off'), seems like a great way to hide the axes while keeping the map visible. That’s a nice way to keep the map clean while still showing just the background.

This solution definitely seems like the right approach if you're looking to focus solely on the map without the axes interfering.

If there are any further tweaks you need, feel free to ask. Great job troubleshooting this!

Sim
Sim le 9 Déc 2025
Thanks to you @Umar, for your hints :-)
Umar
Umar le 10 Déc 2025

No problem @Sim, glad to hear that my hints have helped you.

Connectez-vous pour commenter.

 Réponse acceptée

Sim
Sim le 9 Déc 2025
Modifié(e) : Sim le 9 Déc 2025
I think I found a solution...
geobasemap('grayland')
gx = gca; % Get current axes
set(gx.LatitudeAxis, 'Visible', 'off'); % Hide the latitude axes (ticks and labels)
set(gx.LongitudeAxis, 'Visible', 'off'); % Hide the longitude axes (ticks and labels)
set(gx, 'Box', 'off'); % <-- Optional: remove the box (axes lines)

Plus de réponses (0)

Catégories

En savoir plus sur Geographic Plots dans Centre d'aide et File Exchange

Question posée :

Sim
le 8 Déc 2025

Commenté :

le 10 Déc 2025

Community Treasure Hunt

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

Start Hunting!

Translated by