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

相关推荐
雪之下雪乃的代码日记1 小时前
Python快速入门(Java开发者版)
java·开发语言·笔记·python
Y3815326621 小时前
SERP API 请求体 Gzip 压缩优化实战:大数据量降带宽 80%
开发语言·前端·php
weixin199701080161 小时前
☁️《抖店API基础¥0.018/百次·增值¥0.05/百次:云内云外价差架构实战》(附Python源码)
开发语言·python·架构
萌动的小火苗2 小时前
1、python基础面试题
java·开发语言·python
运维行者_2 小时前
网络监控与ITSM集成:从告警到工单,实现运维自动化闭环
开发语言·网络·分布式·后端·架构·flask·php
小叮当爱咖啡2 小时前
Day3.参数+Prompt三板斧
开发语言·python·prompt
菜冻鱼3 小时前
Python-pandas-索引与筛选
开发语言·笔记·python·numpy·pandas·学习方法
鹿角片ljp3 小时前
Java面试复盘(二):String不可变、字符串常量池与字符串拼接
开发语言·python
小秋求学记.4 小时前
PHP安全漏洞实战:从环境配置到RCE攻击
开发语言·php
看浪的路人4 小时前
第3讲:代码补全引擎
开发语言·windows·python