MATLAB 论文绘图规范标注

在MATLAB中进行绘图时,标注(annotation)是一个重要的功能,它可以用来添加文本、箭头、图形等对象来说明图形中的特定部分。论文出图需要规范,需要有对应的标题、图例、坐标轴信息等。

matlab 复制代码
clear
clc
close all
x = 0:0.1:10;
y1 = sin(x);
y2 = cox(x);

1.标题和标签

  • 使用 title 函数添加图表标题。
  • 使用 xlabel 和 ylabel 函数添加 x 轴和 y 轴的标签。
  • 使用 legend 函数添加图例,解释不同线条或数据系列的含义。
matlab 复制代码
title('Your Title');
xlabel('X Axis Label');
ylabel('Y Axis Label');
legend('Label 1', 'Label 2'); 

2.文本标注

  • 使用 text 函数添加文本标注。
  • 使用 annotation 函数添加更复杂的标注,如箭头、椭圆等。
matlab 复制代码
text(1, 0.5, 'Your Text', 'FontSize', 12);
annotation('arrow', [0.3, 0.1], [0.7, 0.8]);

3.数据标注

使用 text 函数或 annotation 函数将文本标注添加到图表中的特定数据点

matlab 复制代码
text(3, 0.5, 'Data Label', 'FontSize', 10);

4.图形标注

  • 使用 rectangle、line、arrow 等函数创建简单的几何图形。
  • 使用 annotation 函数添加更复杂的图形标注,如箭头、椭圆等。
matlab 复制代码
rectangle('Position', [1, 2, 1, 1], 'EdgeColor', 'r', 'LineWidth', 2);
annotation('arrow', [0.3, 0.1], [0.7, 0.8]);

5.标注样式

调整字体大小、颜色、样式以及标注框的线宽和颜色,以确保标注清晰可读

matlab 复制代码
text(1, 0.5, 'Your Text', 'FontSize', 12, 'Color', 'blue');
annotation('textbox', [0.3, 0.1, 0.5, 0.5], 'String', 'Your Text', 'EdgeColor', 'black');

6.位置和布局

根据需要将标注放置在图表中合适的位置,以便清晰展示数据和信息

matlab 复制代码
% 设置标注文本的位置
x = 0.5;
y = 0.5;
% 添加标注文本
text(x, y, 'Your Text', 'FontSize', 12);

7.注释格式

使用标准的文本格式,如斜体、粗体、下标、上标等,以使标注更具可读性和美观性。

matlab 复制代码
text(x, y, '\bf{Bold Text} \it{Italic Text} \fontsize{12} Text', 'FontSize', 12);

8.以Latex解译方式的数学变量和公式的图形标注

对需要展示的变量或公式,用键盘美元符$符号包含,即$f(x)=sin and cos$,然后在图题(title)、坐标轴标注(XLabel\YLabel)、刻度(XTike/YTike)等代码行中添加

matlab 复制代码
title('$f(x)=sin and cos$','Interpreter','Latex')

9.坐标轴修饰

matlab 复制代码
ax = gca; hold on; box on
ax.XGrid = 'on';
ax.YGrid = 'on';
ax.XMinorTick = 'on';
ax.YMinorTick = 'on';
ax.LineWidth = 1.2;
ax.GridLineStyle = ':';
ax.FontName = 'Cambria';
ax.FontSize = 12;
ax.GridAlpha = .5;

10.移除右上部刻度

matlab 复制代码
box off
ax = axes('Position',get(gca,'Position'),...
'Color','none',...
'XAxisLocation','top',...
'YAxisLocation','right',...
'XColor','k',...
'YColor','k');
set(ax,'YTick', []);
set(ax,'XTick', []);
相关推荐
黑客笔记16 分钟前
Python 进程池和线程池:用等待任务理解并发
开发语言·python
pps-key12 小时前
网络攻防入门:从“黑客梦”到合法实操(生存篇)
开发语言·web安全·php
汤姆宝库13 小时前
BPE分词器的完整实现:字节对合并与词表构建
开发语言·人工智能·c#
驭渊的小故事15 小时前
订单服务如何调用商品服务?一次 RestTemplate 跨服务调用入门
java·开发语言·php
Sakura_j_h_16 小时前
MCP SDK 2.0 实战:用 MCPServer 搭本地笔记检索服务
开发语言·笔记·python·qt·ai工具·mcp·mcpserver
微笑星河q16 小时前
C++STL【vector】常用接口函数使用和迭代器失效问题
开发语言·c++
Eider199817 小时前
Python基础语法之并发相关3
开发语言·python
FRing0317 小时前
vue2干货总结11(短信验证、登录功能、统一处理错误(响应拦截器)、将token信息存入vuex、vuex持久化处理)
开发语言·前端·javascript·vue.js·vue2
CS_Zero18 小时前
DeepSeek V4.1 Flash 1017 (Batch) 新手极速上手指南
开发语言·batch·deepseek
山楂树の18 小时前
Java 字符串高效处理:StringBuilder、StringBuffer、StringJoiner
java·开发语言