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

相关推荐
枕星而眠14 小时前
一篇吃透 C++ 核心基础:初始化、引用、指针、内联、重载、右值引用
开发语言·数据结构·c++·后端·visual studio
Royzst14 小时前
一、集合概述(前置基础)
开发语言·windows·python
Season45014 小时前
C/C++的类型转换
c语言·开发语言·c++
平安的平安14 小时前
Python大模型Function Calling实战:让AI拥有工具使用能力
开发语言·人工智能·python
xyq202414 小时前
Vue.js 实例
开发语言
敲代码的瓦龙14 小时前
Android?碎片!!!
java·开发语言·android-studio
froginwe1114 小时前
SVG 滤镜:全面解析与高效应用
开发语言
枫叶丹414 小时前
【HarmonyOS 6.0】Data Augmentation Kit端侧问答模型:本地化智能问答的技术演进
开发语言·华为·harmonyos
醉舞经阁半卷书114 小时前
LangGraph详解
开发语言·人工智能·python·深度学习·机器学习·自然语言处理
geovindu14 小时前
go:Condition Variable Pattern
开发语言·后端·设计模式·golang·条件变量模式