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

相关推荐
事圆则缓7 小时前
Kotlin 协程完全指南
开发语言·kotlin
我爱写代码i7 小时前
BeLink - 支持生成多种URL 缩短网址PHP源码
开发语言·php·短网址php源码
Java后端的Ai之路7 小时前
20、Python - 备忘录模式
开发语言·人工智能·python·外观模式·备忘录模式
统计学小王子8 小时前
数学建模国赛倒计时4天——《统计模型精讲(混合效应模型R语言实现)》
开发语言·数学建模·r语言
知无不研8 小时前
c语言中循环的介绍与简单应用
c语言·开发语言·算法·循环·for·while
郝学胜-神的一滴8 小时前
Qt 高级编程 045:坐标体系深度实战
开发语言·c++·windows·python·qt·程序人生
dsyyyyy11019 小时前
JS复习,难点,易错点总结
开发语言·javascript·ecmascript
“AI国潮设计-小江”10 小时前
Python实战 | SDXL精准控制“普宁英歌舞×星空蛋糕”IP落地,附核心Prompt与商用授权思路
开发语言·人工智能·python·prompt·aigc
小刘在重生~11 小时前
Java常用类|String类详解 + BigDecimal精准计算(含面试题)
java·开发语言·python
YYYing.11 小时前
【C++进阶系列 (二)】关于线程堆栈的那些事——函数调用过程
开发语言·c++·函数·线程堆栈