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")

相关推荐
程序猿_极客几秒前
【2025 年最新版】Java JDK 安装与环境配置教程(附图文超详细,Windows+macOS 通用)
java·开发语言·windows·macos·jdk
二哈喇子!3 小时前
BOM模型
开发语言·前端·javascript·bom
二哈喇子!3 小时前
空指针异常
开发语言
咚为3 小时前
Rust Print 终极指南:从底层原理到全场景实战
开发语言·后端·rust
%xiao Q3 小时前
GESP C++五级-202406
android·开发语言·c++
Psycho_MrZhang3 小时前
Neo4j Python SDK手册
开发语言·python·neo4j
Traced back4 小时前
# C# + SQL Server 实现自动清理功能的完整方案:按数量与按日期双模式
开发语言·c#
sin22014 小时前
MyBatis的执行流程
java·开发语言·mybatis
web3.08889994 小时前
1688图片搜索API,相似商品精准推荐
开发语言·python
二哈喇子!4 小时前
JAVA环境变量配置步骤及测试(JDK的下载 & 安装 & 环境配置教程)
java·开发语言