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

相关推荐
西门啐血13 分钟前
上位机开发之假装有设备,使用 C# 模拟串口设备
开发语言·mongodb·c#
阿米亚波1 小时前
【C++ STL】std::unordered_multiset
开发语言·数据结构·c++·笔记·stl
我是唐青枫1 小时前
Java ReentrantLock 实战详解:比 synchronized 更灵活的可重入锁
java·开发语言
QH139292318802 小时前
# R&S ZNB43 ZNA43 ZNA67矢量网络分析仪
开发语言·网络·php
脚踏实地皮皮晨2 小时前
003003001_Grid控件
开发语言·windows·算法·c#·visual studio
十年磨剑走天涯2 小时前
C++ STL 容器操作复杂度速查表
开发语言·c++
always_TT3 小时前
【Python requirements.txt 依赖管理】
开发语言·python
15Moonlight3 小时前
C++进阶(09):特殊类设计
开发语言·c++
宁风NF3 小时前
JavaScript:网络请求与前端通信
开发语言·前端·javascript·网络·学习·ecmascript
Logintern093 小时前
py文件开头为什么需要加:from __future__ import annotations
开发语言·python