amssymb LaTeX symbols in plots

조회 수: 22 (최근 30일)
Christian Schröder
Christian Schröder 2022년 8월 17일
댓글: Christian Schröder 2022년 8월 23일
Good afternoon,
I'm often using LaTeX to annotate plots created in MATLAB, e.g. (this is obviously just a silly example)
plot(0:0.01:2*pi, sin(0:0.01:2*pi))
text(4, 0.8, '$X > 0$', 'Interpreter', 'latex')
This is fine --- until you need a symbol not provided by base (La)TeX but rather by a LaTeX package such as amssymb. For example,
text(4, 0.8, '$X \gtrless 0$', 'Interpreter', 'latex')
will not work and instead produce a warning ("String scalar or character vector must have valid interpreter syntax: $X \gtrless 0$").
Is there a way to use such symbols from within MATLAB? Alternately, is there some other way of producing the \gtrless symbol, specifically?
Thank you & keep the cheer,
Chris

답변 (1개)

Kartikay Sapra
Kartikay Sapra 2022년 8월 23일
The following documentation shows the list of supported Greek symbols and special characters (along with corresponding syntax):
Setting the Interpreter property 'latex' allows additional formatting.
Specifically, for '>=' latex symbol in a MATLAB plot.
Use:
plot(0:0.01:2*pi, sin(0:0.01:2*pi))
text(4, 0.8, '$X \geq 0$', 'Interpreter', 'latex')
  댓글 수: 1
Christian Schröder
Christian Schröder 2022년 8월 23일
Thanks for the link to the list of supported symbols, that's very helpful! Unfortunately \geq is not the one I'm looking for, however.

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

카테고리

Help CenterFile Exchange에서 Labels and Annotations에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by