Matlab图坐标轴数值负号改为减号(change the hyphen (-) into minus sign (−, “U+2212”))

在MATLAB中,坐标轴负数默认符号是 - ,如下图所示

python 复制代码
x = 1:1:50;
y = sin(x);
plot(x,y)

可通过以下两语句将负号修改为减号:

python 复制代码
set(gca,'defaultAxesTickLabelInterpreter','latex');
yticklabels(strrep(yticklabels,'-','$-$'));

或者

python 复制代码
set(gca, 'TickLabelInterpreter', 'latex')
ytickformat('$%g$')

示例:

python 复制代码
x = 1:1:50;
y = sin(x);
plot(x,y)
set(gca,'defaultAxesTickLabelInterpreter','latex');
yticklabels(strrep(yticklabels,'-','$-$'));
python 复制代码
x = 1:1:50;
y = sin(x);
plot(x,y)
set(gca, 'TickLabelInterpreter', 'latex')
ytickformat('$%g$')

参考链接:change the hyphen (-) into minus sign (−, "U+2212")

相关推荐
阿巴~阿巴~21 分钟前
冒泡排序算法
c语言·开发语言·算法·排序算法
看到我,请让我去学习2 小时前
QT - QT开发进阶合集
开发语言·qt
weixin_307779132 小时前
VS Code配置MinGW64编译SQLite3库
开发语言·数据库·c++·vscode·算法
励志不掉头发的内向程序员3 小时前
STL库——string(类函数学习)
开发语言·c++
一百天成为python专家3 小时前
Python循环语句 从入门到精通
开发语言·人工智能·python·opencv·支持向量机·计算机视觉
Sunhen_Qiletian3 小时前
朝花夕拾(五)--------Python 中函数、库及接口的详解
开发语言·python
hqwest3 小时前
C#WPF实战出真汁07--【系统设置】--菜品类型设置
开发语言·c#·wpf·grid设计·stackpanel布局
前路不黑暗@4 小时前
C语言:操作符详解(二)
c语言·开发语言·经验分享·笔记·学习·学习方法·visual studio
深盾科技5 小时前
Kotlin Data Classes 快速上手
android·开发语言·kotlin
zzywxc7875 小时前
详细探讨AI在金融、医疗、教育和制造业四大领域的具体落地案例,并通过代码、流程图、Prompt示例和图表等方式展示这些应用的实际效果。
开发语言·javascript·人工智能·深度学习·金融·prompt·流程图