How to prevent MATLAB printing false space and use wrong fonts?

偶尔善良 提交于 2019-12-04 03:00:02

I'm using R2015b on my linux machine, but I get the same issues when printing.

All the strings shown in a plot are passed to an interpreter before they are passed to the renderer. There are three modes for the interpreter 'tex' (default),'latex' and 'none'.

Changing Fonts

The TeX / LaTeX interpreter will not check your OS fonts, but brings its own set of fonts for displaying included here:

  1. Windows: C:\Program Files\MATLAB\<version>\sys\fonts\ttf\cm
  2. Linux: <MATLAB root>\<version>\sys\fonts\ttf\cm

For me I have the first part of the BaKoMa Fonts Collection (according to my readme). The following fonts are aviable (to me):

============================ Basic text fonts ==========================
cmr 5   6   7   8   9   10  12  17
cmbx    5   6   7   8   9   10  12
cmti            7   8   9   10  12
cmsl                8   9   10  12
cmcsc               8*  9*  10 
cmtex               8   9   10
cmb                     10  
cmbxsl                      10
cmbxti                      10 

where cm = computer modern (from what I can tell).

So even if you tell matlab to plot it in Helvetica, matlab passes it to TeX and TeX doesn't know what Helvetica is and just uses its default font instead. One could think about adding helvetica manualy, but I didn't explore that further.

Dealing with the (annoying) spaces

To remove the spaces in ylabel you can pass a latex string. For this change

ylabel('Space-bugs (\mum^2) (µm²) (µm^2)')

to

ylabel('Space-bugs ($\mu m^2$) ($\mu m^2$) ($\mu m^2$)','interpreter','latex');

However this will use the cmr (computer modern regular) font and not Helvetica, but remove the space bug.

To avoid a mix of fonts in the plot, the interpreter of all text fields can be changed to latex. Unless you have the computer modern font aviable on your OS, in which case you can simply set the appropriate font type in matlab.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!