Degree symbol formatting problems

조회 수: 5 (최근 30일)
Andrew Yool
Andrew Yool 2020년 9월 11일
댓글: Andrew Yool 2020년 11월 27일
Why does Matlab insert spaces in my axis labels like those in the right-hand plot here? ...
If I use the special character for the degree sign, everything's fine like the left-hand side. And it doesn't seem to matter if I choose 'tex' as my 'Interpreter' option ...
figure(1); clf;
subplot (1,2,1); hold on;
[...]
xlabel ('Longitude [°E]'); ylabel ('Latitude [°N]');
title ('2012'); topbox; axis equal;
axis ([-20.5 -13.5 46 52]); set (gca, 'XTick', -20:2:-14, 'YTick', 46:2:52);
subplot (1,2,2); hold on;
[...]
xlabel ('Longitude [{\circ}E]'); ylabel ('Latitude [{\circ}N]', 'Interpreter', 'tex');
title ('2014'); topbox; axis equal;
axis ([-20.5 -13.5 46 52]); set (gca, 'XTick', -20:2:-14, 'YTick', 46:2:52);
pos = get (gca, 'Position'); cb = colorbar ('horiz'); cbpos = get(cb, 'Position');
cbpos(2) = pos(2) - cbpos(4); set (cb, 'Position', cbpos); set (gca, 'Position', pos);
caxis ([0 12]); set (cb, 'XTick', 0.5:1:11.5, 'XTickLabel', ['J'; 'F'; 'M'; 'A'; 'M'; 'J'; 'J'; 'A'; 'S'; 'O'; 'N'; 'D']);
paper; orient portrait; oname = sprintf('modis_timeseries_v4_0X'); print ('-depsc', '-painters', oname);
I get the same sort of behaviour with Matlab v2020a if I try to use superscript - anomalous spacing in my labels. What am I doing wrong?
I know this sort of question has been asked before, but I'm not finding the solution working for me.
Thanks in advance for any help anyone can offer.
  댓글 수: 1
Andrew Yool
Andrew Yool 2020년 11월 27일
I don't imagine many people will be reading this, but I wanted to follow up in case anyone else comes across this same problem down the line.
In summary, it now looks to me like this has something to do with my Linux environment's vector-writing software. The script below produces a series of figure files in different formats (of which pngconvert just uses ghostscript to do the EPS to PNG conversion) ...
x = 1:1:10;
y = x.^2;
figure(1);
plot (x,y,'b-', x, y, 'ro');
xlabel ('Property 1 [blah{\circ} blah^{-3}]');
ylabel ('Property 2 [blah° blah-3]');
exportgraphics(gca, 'test_PDF_vec.pdf', 'ContentType', 'vector');
exportgraphics(gca, 'test_PDF_img.pdf', 'ContentType', 'image', 'Resolution', 300);
exportgraphics(gca, 'test_PNG.png', 'Resolution', 300);
print ('-depsc', '-painters', 'test_EPS');
pngconvert('test_EPS.eps', 300);
Of these figures (and I've attached all bar the EPS one; this environment doesn't like that), the vector ones (including the PNG created from the EPS) exhibit the space problems in the units, regardless of whether they're printed using the print command or exportgraphics. Meanwhile the image ones (including the PDF) do not have this problem.
I'm not familiar enough with my Linux environment to dig into this [*], so I don't have an answer for why this happens, but as I can now produce image files in the way that I want, I'm now happy.
[*] I've loaded texlive/2018 to access ghostscript if that helps!

댓글을 달려면 로그인하십시오.

답변 (1개)

madhan ravi
madhan ravi 2020년 9월 11일
I certainly do not see that behaviour 2020a.
  댓글 수: 1
Andrew Yool
Andrew Yool 2020년 11월 27일
It would appear not to be a 2020a issue, but perhaps something to do with another part of my local Linux environment. As the comment I've added to my question shows, I can also get what I want with 2020a if I ask Matlab in the right way, i.e. image graphics rather than vector graphics.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Printing and Saving에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by