How to change the font of ticks in a colorbar?

조회 수: 84 (최근 30일)
Lukas Bathelt
Lukas Bathelt 2016년 10월 4일
댓글: Chien-Han Su 2022년 1월 26일
I have a matlab polt and everything like label and title is interpreted in latex style. There is also a colorbar in this figure and I want the ticks at this colorbar in latex style too.
For the rest I have code like this
if true
set(0,'DefaultTextInterpreter','latex')
set(0,'DefaultLegendInterpreter','latex')
end
and it runs very good, but I can't find kind of this code for the ticks at the colorbar.
Would be really nice if someone's out there who can help me ;)

채택된 답변

Marc Jakobi
Marc Jakobi 2016년 10월 4일
편집: Walter Roberson 2016년 10월 8일
Changing the TickLabelInterpreter won't make it match the latex serif roman numbering style, which is what I assume you want to do. However, you can change the FontName property.
A good set of fonts that match the LaTeX fonts can be downloaded here: Computer Modern Unicode fonts
You will need 7zip to unpack the archive and then you will have to install a font of your choice (in Windows, double-click on the font to open it and then install). Then restart Matlab.
An example for changing the colorbar and axes font would be:
ax = axes;
c = colorbar;
ax.FontName = 'CMU Serif Extra'; %installation file: cmunsl.ttf
c.FontName = 'CMU Serif Extra';
  댓글 수: 4
Marc Jakobi
Marc Jakobi 2016년 10월 8일
Cheers!
Pavaman
Pavaman 2018년 11월 6일
This answer is not great because when printing to a vector file format such as eps, emf or pdf, only a select set of fonts are permissible. It will default to one of these when printing. See here .

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

추가 답변 (3개)

Massimo Zanetti
Massimo Zanetti 2016년 10월 4일
Set TickLabelInterpreter property to 'latex'
  댓글 수: 2
Pavaman
Pavaman 2018년 11월 6일
Thanks for this answer. It saved me. I was using the colorbar Label Interpreter property and trying to change that to no avail. the TickLabelInterpreter property was the one I was looking for. An hour of MATLAB answers scouring led me to here.
Chien-Han Su
Chien-Han Su 2022년 1월 26일
This saves me too! Thanks!

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


Mehedi Hassan
Mehedi Hassan 2020년 10월 28일
this will set your colorbar ticks to latex font:
c = colorbar;
set(c,'TickLabelInterpreter','latex')

Lukas Bathelt
Lukas Bathelt 2016년 10월 5일
Thanks for the fast answers guys. With your help it's working now.
@ Massimo Zanetti: I tried the TickLabelInterpreter before, but it didn't work.
  댓글 수: 1
Marc Jakobi
Marc Jakobi 2016년 10월 8일
No problem. If one of the answers solved your problem, would you please accept it as an answer?

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

카테고리

Help CenterFile Exchange에서 Graphics Object Properties에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by