Matlab字体在打印或导出时无法正确呈现 [英] Matlab Fonts Not Rendering Correctly on Print or Export

查看:192
本文介绍了Matlab字体在打印或导出时无法正确呈现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试制作一个非常适合LaTeX文档的Matlab图形.一个已知的问题是XTickLabel和YTickLabels不使用LaTeX解释器进行渲染,从而导致图形看起来很糟糕. (注意:我意识到有一些修复方法,涉及用文本对象替换tex标签(即 format_tics ),但是在绘制多个图形时,这些解决方案并不简单,并且存在各自的问题,需要对每个图形进行大量调整.)

I'm trying to make a matlab figure that nicely fits into a LaTeX Document. A known problem is that the XTickLabel and YTickLabels do not render using the LaTeX interpreter, causing bad looking plots. (Note: I realize there are some fixes out there that involve replacing the tex labels with text objects (i.e. format_tics), however these solutions are non-trivial when plotting multiple figures, and come with problems of their own that require a lot of tweaking for each individual figure.)

我觉得通过更改字体来解决此问题,而不是替换图形中的对象,这会更优雅.

I feel that approaching this problem through changing the font, as opposed to replacing objects in a figure, is a little more elegant.

下载了LaTex字体的.otf 版本,并将其设置为显示在整个图中:

I downloaded a .otf version of the LaTex font, and set that to display throughout the figure:

    set(0,'defaulttextinterpreter','latex')
    set(0,'DefaultTextFontSize', 10)
    set(0,'DefaultTextFontname', 'CMU Serif')
    set(0,'DefaultAxesFontSize', 10)
    set(0,'DefaultAxesFontName','CMU Serif')

在Matlab图形窗口中看起来不错;但是,在打印时,事情会分崩离析.

Things look good in the matlab figure window; however when printing, things fall apart.

如果我使用"painters"渲染器打印(使用导出GUI或打印命令),则字体看起来很滑稽且前后不一致.某些符号将无法正确显示,并且在整个打印图形中会出现不同的字体.

If i print (either using the export GUI or the print command) using the "painters" renderer, the fonts look funny and inconsistant throughout. Some symbols will not display correctly, and different fonts appear throughout the printed figure.

 print('-depsc','-painters',['InstP.eps'])        

如果我切换到zbuffer渲染器,字体会变得一致,但是还有其他错误.质量下降,并且一些文本被忽略(或被其他文本覆盖).

If i switch to the zbuffer renderer, the fonts become consistant, but there are other bugs. The quality drops, and some text is left out (or covered by other text).

 print('-depsc','-zbuffer',['InstZ.eps'])  

opengl到处都是一团糟.

The opengl is just a mess everywhere.

有人知道为什么这些渲染器在使用这些字体时遇到麻烦吗?还有使字体正确呈现的变通办法吗?

Does anybody know why these renders are having trouble with these fonts? And any work-arounds to get the fonts to render correctly?

示例代码:

    subplot(1,2,1)
         imshow(IMG,'XData',XDat,'YData',YDat);
         axis image;axis([0 20 -5 5]);
         xlabel('$x^*$');
    subplot(1,2,2)
    imshow(SqImg,'XData',Xs,'YData',Xs);
    xlabel('$\Phi_B$');
    ylabel('$\Phi_A$');
    axis square;
    set(gca,'YDir','normal',...
            'XAxisLocation','bottom',... 
            'YAxisLocation','left',... 
         'XTick',(0:.5:1).^Exp,'XTickLabel',0:.5:1,...
         'YTick',(0:.5:1).^Exp,'YTickLabel',0:.5:1);


 print('-depsc','-painters',['InstP.eps'])        
 print('-depsc','-zbuffer',['InstZ.eps'])        

推荐答案

我使用imwrite命令而不是print命令将图形转换为图像文件,但这不适用于EPS.

I use the imwrite command instead of the print command to turn the figures into image files, but this doesn't work with EPS.

fhand = figure();
subplot(1,2,1);
...
I = getframe(fhand)
imwrite(I.cdata,'Inst.png','PNG')

这篇关于Matlab字体在打印或导出时无法正确呈现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆