change the hyphen (-) into minus sign (−, “U+2212”)

389 次查看(过去 30 天)
Hi,
How can I change the hyphen (-) into minus sign (−, “U+2212”) in Matlab plot!
the figure above generated from matlab which has the defalt minus sign. how can I change -20 -40 and -60 to −20 −40 and −60
  4 个评论
Omri Davidson
Omri Davidson 2023-1-12
You can also write the minus sign by using char(8722) with the regular tex interperter.
Walter Roberson
Walter Roberson 2023-1-12
True. However, the original poster needs to use Latex, and Latex does not support unicode characters,

请先登录,再进行评论。

采纳的回答

Chunru
Chunru 2022-6-17
set(groot,'defaultAxesTickLabelInterpreter','latex');
plot(randi([-60 60], [20, 1]))
xticks(-60:20:60)
yticklabels(strrep(yticklabels,'-','$-$'));
  3 个评论
Haiyao Yu
Haiyao Yu 2023-1-20
If you use tex as the format control, you can run the following command alone, note that the first is a hyphen, and the second is a minus sign.
xticklabels(strrep(xticklabels,'-','–'));
yticklabels(strrep(yticklabels,'-','–'));

请先登录,再进行评论。

更多回答(3 个)

Walter Roberson
Walter Roberson 2022-6-17
编辑:Walter Roberson 2023-1-12
plot(randi([-60 60], [20, 1]))
xticks(-60:20:60)
set(gca, 'TickLabelInterpreter', 'latex')
ytickformat('$%g$')
  3 个评论
yiting liu
yiting liu 2022-8-23
May I ask that how to change the hyphen (-) into minus sign (−, “U+2212”) when using "contour"?
Walter Roberson
Walter Roberson 2022-8-23
[cmat, h] = contour(....);
clabel(cmat, h);
set(h.TextPrims, 'Interpreter', 'latex');
Have a look at that and see if it does what you need. If not, then it might be necessary to modify the h.TextPrims 'String' properties.

请先登录,再进行评论。


Changliang Xiong
Changliang Xiong 2022-8-23
I recommend to save the .fig as *.pdf.Then,adobe illustrator could be used to directly modify the sign.

Jan Kelner
Jan Kelner 2024-1-30
Is it possible to change the 'hyphen' to 'minus' sign in the heatmap values and colorbar scale values?

类别

Help CenterFile Exchange 中查找有关 Line Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by