Change map coordinates to Latex Interpreter

I am making a figure, I want it to use latex interpreter for the axis labels, but I fail at it, maybe because I use the m_map package.
figure
m_proj('lambert','lon',[10 20],'lat',[25 31]);
m_gshhs_c('patch',[.8 .8 .8],'edgecolor','none');
m_grid('linewi',2,'tickdir','out','fontsize',24);
I tried using latex interpreter, but it does nothing.
set(gca, 'TickLabelInterpreter', 'latex');
Any idea what am I missing?

 採用された回答

Madmad
Madmad 2026 年 3 月 12 日

0 投票

Solution for people having the same issue: After you call m_grid, m_map package reattributes your x and y axis ticks to X°N or Y°E. To remove the ugly default font, switch each to latex.
allText = findobj(gcf, 'Type', 'Text');
for i = 1:length(allText)
txt = allText(i).String;
if ~isempty(txt)
newTxt = regexprep(txt, '(\d+)[°]?([NSEW]?)', '$1$^{\\circ}$$2');
if ~strcmp(txt, newTxt)
allText(i).Interpreter = 'latex';
allText(i).String = newTxt;
end
end
end

その他の回答 (1 件)

Adam Danz
Adam Danz 2024 年 5 月 29 日
編集済み: Adam Danz 2024 年 5 月 31 日

1 投票

The map axes you see is a psuedo-axes created from a patch with labels to appear as an axes. The actual axes is not visible. So when you set the TicklabelInterpreter, it has no visible effect.
For confirmation of this, turn on the visibility of the axes,
set(gca,'Visible','on')
I'm not familiar with the 3rd party toolbox these functions appear to be from (link?). See the Mapping Toolbox for alternatives.

1 件のコメント

Madmad
Madmad 2024 年 5 月 29 日
Yes this link. I used to use it because of Matlab lack of toolboxes for maps, I plan to switch to the one you linked!

サインインしてコメントする。

カテゴリ

タグ

質問済み:

2024 年 5 月 29 日

回答済み:

2026 年 3 月 12 日

Community Treasure Hunt

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

Start Hunting!

Translated by