I would like to know how to make sure the latitude labels have decimals in them.
3 views (last 30 days)
Show older comments
I have this code creating a map of a small portion of Antarctica. I have the latitude lines appearing ever half of a degree, but the labels still show single degrees. Is it possible to have the labels have decimals?
Also is it possible to have the longitude lines appear with labels on the map instead of on the edge?
The base of the map is Bedmap.
figure('Color','w')%Colors the figure white .
set(gca, 'Color', 'none');
mapzoom(-81.6, -148.8);%'size',[100 100]);
framem on ; gridm on ; mlabel on ; plabel on ;
bedmap2('gl','color','k','linewidth',1)
bedmap2('coast')
setm(gca,'plinelocation',.5,'plabellocation',0.5 ,...
'labelrotation','on');
hold on;
3 Comments
dpb
on 25 Jun 2024
You'll need to submit a minimum working example -- but in general the answer to the question would be whatever is the equivalen with an axesm axis object as the following for a regular axis.
hAx=gca;
hAx.XAxis.TickLabelFormat='%.1f';
The default axis is a NumericRuler; the map axis is undoubtedly some other object and so may have different properties, but one of the will be the format string that is undoubtedly set to '%g' by default which cause the butt-ugly display of mixing plain integer and fixed format strings together. This behavior has irritated me no end since the initial introduction of MATLAB.
Answers (1)
dpb
on 26 Jun 2024
Edited: dpb
on 26 Jun 2024
Anywhere after the axis is created...for ease of coding, save the handle to the axis object when creating it.
You haven't provided any code that can be run without other pieces/things you haven't supplied so all can do is talk generalities...I don't have the Mapping TB so can't play except here.
axesm;
hAxm=gca;
"Code Run Timed Out
Your code took longer than 235 seconds to run. Simplify code and then run again."
Well, not sure how one would simplify a single function call with zero arguments; looks as though this platform won't let is illustrate with actual code...
But, it appears from the doc on <axesm Properties> the axesm object doesn't do the tick labels the same way by specifying a format string as above, but by a precison, _
MLabelRound — Specify significant digits for meridian labels
0 (default) | integer scalar
Specify significant digits for meridian labels — Specifies to which power of ten the displayed labels are rounded. For example, if MLabelRound is -1, labels are displayed down to the tenths. The default value of MLabelRound is 0; that is, displayed labels have no decimal places, being rounded to the ones column (100).
There's a second,
PLabelRound — Specify significant digits for parallel labels
So, the above would instead be something like
axesm('MLabelRound',-1,'PLabelRound',-1);
to create the axes and set the precison to tenths on creation.
It also appears there is a special set of set/get functions specifically, setm to make changes after the fact.
The documentation doesn't show it returning a handle to the object; the examples only show using setm/getm and not referencing the structure properties with the named doc convention, but one would presume this would also be possible. But, I can't test...
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!