Hide (or remove) the geoaxes in geobasemap
5 commentaires
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!
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!
No problem @Sim, glad to hear that my hints have helped you.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Geographic Plots dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


